Payload array - how to sort?

I'm looking for a way to play with data from ERP system. Idea is to create a dashboard which shows list of customers and status/qty of orders.

I was able to get the data from Excel file to NR. Structure of excel table and massage payload are show in the picture.

Question is how to sort the data by customers ( column C) and sum q'ty (column N) ?

Thanks for advise.

search this forum for node-red-node-ui-table and there are lots of examples that come with it.

Maybe it's easier and nicer to use node-red-node-ui-table.
With this you can easy sort.

If you need to sort and am not using ui-table then the javascript sort() method can be passed a compare function so you can sort on a particular attribute of the structure.

This can also be done in a change node using a 1 line jsonata expression.


Share your payload to be sorted in text format and I (or others) will give you the jsonata expression.

1 Like

Hi janvda ,

Payload in text format attached. My programming skills are not good enough to solve this problem by myself.

array.txt (6.4 KB)


The jsonata expression


See it at work:


  • I have assumed that the array is stored in the msg.payload.
  • I have assumed that you wanted it to be sorted first on column C and then on column N.

The expression can be easily used in a node-red change node to convert the input in sorted output.

Thank janvda, it works.
I've made a easier table to see better what's really happening.

How to use expresion in switch node ?
In other words how to swich msg.payload based on customers - to have separate payload of each of them ?

If customer is "a" - one msg , if "b: - second msf. and so on.

It is not really clear what you want.

Maybe instead of a single switch node you can consider a switch node where each output is followed by a change node.

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