# How sort data into ui\_dropdown

**URL:** <https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750>\
**Category:** Dashboard\
**Created:** [5 December 2021 15:53 UTC](https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750 "2021-12-05T15:53:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geppy57](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Geppy57](https://discourse.nodered.org/u/Geppy57)\
**Post date:** [5 December 2021 15:53 UTC](https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750/1 "2021-12-05T15:53:42Z")

</div>

Hi all.  
A simple question.  
There is a simple way to sort data into ui\_dropdown node?  
I store files hourly in order to view historical charts.  
The files are named by date and time.  
To select file I put a ui\_dropdown node.  
When the dropdown opens, it show files from months ago and is necessary to scroll the entire list to see the last file.  
Is it possible to see the last file on the top, not the first?  
BR

P.S : the dropdown shows only data that comes from another source. The SORT node can adjust the list as desired SORRY

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 December 2021 16:12 UTC](https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750/2 "2021-12-05T16:12:25Z")

</div>

Here is an example, had to guess your format as you give no examples

```auto
[{"id":"2073515d.335abe","type":"inject","z":"88fadd65b9040724","name":"","props":[{"p":"options","v":"[\"2021-12-4 10:32:00\",\"2021-12-4 11:32:00\",\"2021-12-4 12:32:00\"]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":840,"wires":[["c330be0.ed88fc","6b899d3c.9525f4"]]},{"id":"c330be0.ed88fc","type":"change","z":"88fadd65b9040724","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"options^(>$)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":840,"wires":[["6b899d3c.9525f4"]]},{"id":"6b899d3c.9525f4","type":"debug","z":"88fadd65b9040724","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"options","targetType":"msg","statusVal":"","statusType":"auto","x":520,"y":880,"wires":[]}]

```

> **[Path Operators · JSONata](https://docs.jsonata.org/path-operators#---order-by)**
>
> The path operators underpin the declarative nature of the map/filter/reduce processing model in JSONata.

Similar can be doe with function node using sort()  
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Array/sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)  
I have never used the sort node but that should work to.

---

<div class="post-metadata">

**Author:** ![Geppy57](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Geppy57](https://discourse.nodered.org/u/Geppy57)\
**Post date:** [6 December 2021 09:27 UTC](https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750/3 "2021-12-06T09:27:10Z")

</div>

Hello.  
Your suggestion is very useful.  
I attach a sample code and debug window.  
BR

 ![Sorting](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/ddaf55d4f937291b8114b26c5c8a4799aa7aa92b.jpeg)  
[Data directory sorted.json](https://discourse.nodered.org/uploads/short-url/svVAhXNaezjq9CYz3REwYa170vB.json) (2.1 KB)

---

<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:** [20 December 2021 09:27 UTC](https://discourse.nodered.org/t/how-sort-data-into-ui-dropdown/54750/4 "2021-12-20T09:27:51Z")

</div>

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