# Help to sort by a column the data entered in node ui\_tablet

**URL:** https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711
**Category:** General
**Created:** [4 December 2021 15:09 UTC](https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711 "2021-12-04T15:09:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![carflomi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carflomi/32/45646_2.png) [@carflomi](https://discourse.nodered.org/u/carflomi)
#### Post date: [4 December 2021 15:09 UTC](https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711/1 "2021-12-04T15:09:22Z")

</div>

Hello.  
I present you my problem  
I have a Ui\_tablet node that works great.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c74edfcbc77643bde1c72f8f8732ffcf786d6f4c.png).  
But I am not able to sort the data from newest to oldest (in the image you can see that the "Timestamp" field is sorted from oldest to newest, just the opposite of how I want).  
I give some data on how I fill the table and how I have configured it.

1. Column configuration

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f332c40b5ee2f38e309bdb6a4928078bcdaa679.png)

1. Add a row

```auto
msg.payload={
    command:"addRow",
    arguments: [
        
            msg.payload,
            false
    ],
    returnPromise: true
}
return msg;

```

Where msg .payload is (by example)

```auto
var now = new Date();
var yyyy = now.getFullYear();
var mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based
var dd = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
var hh = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
var mmm = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
var ss = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
msg.payload = {
    //"timestamp" : + yyyy + "/"+ mm + "/" + dd + " " + hh + ":"+ mmm + ":" + ss ,
    "timestamp" : + dd + "/"+ mm + "/" + yyyy + " " + hh + ":"+ mmm + ":" + ss ,
    "Evento": "Orden HMI sobre DBT , APERTURA",
    "status" : "#1FFDFE",
}
return msg;

```

Can you guide me on my doubt?

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [5 December 2021 12:30 UTC](https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711/2 "2021-12-05T12:30:37Z")

</div>

Hi,

`AddRow` adds rows to the end **or** at the top

> The second argument is optional and determines whether the row is added to the **top** or bottom of the table. A value of `true` will add the row to the **top** of the table, a value of `false` will add the row to the **bottom** of the table.

[as described here](http://tabulator.info/docs/5.0/update#row) You send `false` so new lines are added to the bottom resulting in the table sorted ascending.

you can trigger the sort by [`setSort()`](http://tabulator.info/docs/5.0/sort#manage)

and by using the [arrow keys on the header](http://tabulator.info/docs/5.0/sort#header). (if you use these it is perhaps good to know that you can receive the current sorting by `getSorters()` and then add your new lines at the top or at the end depending which state is set. _Maybe this can be tricky if you have multiple clients showing the data because they might be not in sync,_

How to scroll to the new line I think I already answered here [Problem with data displayed in UI-Table when switching Tabs - #7 by Christian-Me](https://discourse.nodered.org/t/problem-with-data-displayed-in-ui-table-when-switching-tabs/48940/7)

---

<div class="post-metadata">

### Author: ![carflomi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carflomi/32/45646_2.png) [@carflomi](https://discourse.nodered.org/u/carflomi)
#### Post date: [6 December 2021 11:35 UTC](https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711/3 "2021-12-06T11:35:39Z")

</div>

thank you now it's working

---

<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: [4 February 2022 11:35 UTC](https://discourse.nodered.org/t/help-to-sort-by-a-column-the-data-entered-in-node-ui-tablet/54711/4 "2022-02-04T11:35:44Z")

</div>

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