# Sort node not working with split node

**URL:** <https://discourse.nodered.org/t/sort-node-not-working-with-split-node/31466>\
**Category:** General\
**Created:** [12 August 2020 10:21 UTC](https://discourse.nodered.org/t/sort-node-not-working-with-split-node/31466 "2020-08-12T10:21:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sangoku](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sangoku/32/27166_2.png) [@Sangoku](https://discourse.nodered.org/u/Sangoku)\
**Post date:** [12 August 2020 10:21 UTC](https://discourse.nodered.org/t/sort-node-not-working-with-split-node/31466/1 "2020-08-12T10:21:27Z")

</div>

I am getting a collection of entities from Home Assistant and i am trying to sort the entities by name

The sort function just wont sort the incoming data... any idea why?

Here is the code:

Here is one of the entities im trying to sort:

```auto
{"entity_id":"light.step01","state":"off","attributes":{"effect_list":["None","Random Color"],"friendly_name":"step01","supported_features":61},"last_changed":"2020-08-12T08:43:02.604431+00:00","last_updated":"2020-08-12T08:43:02.604431+00:00","context":{"id":"7a980f57efd04ff09e8226f51c78b13a","parent_id":null,"user_id":null},"timeSinceChangedMs":5400231}

```

The flow:

```auto
[{"id":"a7111d80.930cf","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a8ecd3f.0c2a33","type":"debug","z":"a7111d80.930cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":740,"wires":[]},{"id":"c95583cb.6a5b5","type":"sort","z":"a7111d80.930cf","name":"","order":"ascending","as_num":false,"target":"","targetType":"seq","msgKey":"","msgKeyType":"elem","seqKey":"payload","seqKeyType":"msg","x":730,"y":640,"wires":[["a8ecd3f.0c2a33"]]},{"id":"41115106.53eb","type":"split","z":"a7111d80.930cf","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":580,"wires":[["54ba328b.32e36c","c95583cb.6a5b5"]]},{"id":"50e8a5b2.077dec","type":"ha-get-entities","z":"a7111d80.930cf","server":"aa148f9e.e5c97","name":"","rules":[{"property":"entity_id","logic":"is","value":"light\\.step[^a-z][^a-z]","valueType":"re"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":500,"y":740,"wires":[["41115106.53eb"]]},{"id":"54ba328b.32e36c","type":"debug","z":"a7111d80.930cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":860,"wires":[]},{"id":"95e62f23.d38e1","type":"inject","z":"a7111d80.930cf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":740,"wires":[["50e8a5b2.077dec"]]},{"id":"aa148f9e.e5c97","type":"server","z":"","name":"Home Assistant","addon":true}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 August 2020 10:59 UTC](https://discourse.nodered.org/t/sort-node-not-working-with-split-node/31466/2 "2020-08-12T10:59:28Z")

</div>

> [@Sangoku](#):
>
> i am trying to sort the entities by name

The entity you posted does not appear to have an attribute called "name", so what are you trying to sort on? If you mean freindly\_name then you need to sort on something like `payload.attributes.friendly_name`. Read the node red docs page Working with Messages which will provide useful help with identifying attributes in a complex object.

---

<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:** [11 October 2020 10:59 UTC](https://discourse.nodered.org/t/sort-node-not-working-with-split-node/31466/3 "2020-10-11T10:59:38Z")

</div>

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