# Change node to sort/separate differents objects in array

**URL:** <https://discourse.nodered.org/t/change-node-to-sort-separate-differents-objects-in-array/65308>\
**Category:** General\
**Tags:** http-request, database, mqtt\
**Created:** [19 July 2022 09:47 UTC](https://discourse.nodered.org/t/change-node-to-sort-separate-differents-objects-in-array/65308 "2022-07-19T09:47:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaSa](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@SaSa](https://discourse.nodered.org/u/SaSa)\
**Post date:** [19 July 2022 09:47 UTC](https://discourse.nodered.org/t/change-node-to-sort-separate-differents-objects-in-array/65308/1 "2022-07-19T09:47:31Z")

</div>

hello all,

I have an api request from my database containing some data, the aim is to sort them and send in separate messages or in differents objects at least.

the using code is :

```auto
downlinks = [];

for (var i = 0; i < msg.payload.length; i++) {
    
    downlink = {};
    downlink.eui = msg.payload[i].valve_EUI;

    if (msg.payload[i].System_Activated === null ) {
        downlink.payload = new Buffer("00", "hex");
    } else {
        downlink.payload = new Buffer( "01", "hex");
    }
     

    downlink.port = 1;
    downlink.ack = true;
    downlink.Rxwindows = 1;

    downlinks.push(downlink);
}

return {downlinks};

```

the general form of my result message is _**[{xxxxx}, {yyyyyy}, ...]**_,

Could you please help me if I need the result in this format : _ **{xxxxx}, {yyyyyy}, ...** _

actually i'm using change node by set option I put msg.downlinks to downlinks [0], but the problem is that it results me just the first array, it means : {xxxxx}

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec235a5c057abb733fec654592da7241d5870012.png)  
\*\*

thanks in advance.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 September 2022 09:48 UTC](https://discourse.nodered.org/t/change-node-to-sort-separate-differents-objects-in-array/65308/2 "2022-09-17T09:48:29Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
