How to sort Arrays/Lists in Workato?

Ong Ting Wei
2 min readJul 9, 2021

--

There are times where we need to display information in an ordered fashion. So here are 2 ways of sorting an array/list in Workato:

  1. Ruby code connector. This is available for all plans. It involves 1 line of code and that’s it. Short and simple.
  2. Collection connector. This connector comes with the Workato’s big data add-on. There are no coding involved in this.

1. Ruby code connector

Sample recipe here.

This is the ruby code that you will need.

{ sorted_test: input[“tests”].sort_by { |test| test[‘name’] } }

Remember to toggle to formula mode to map a List datapill into the input field.

And you may need to tweak your code accordingly to your data and how you want to sort it.

And you’re all done.

2. Collection connector

Sample recipe here.

We are going to create a list in Collection using the Array/List that you have.

Next, we will query the Collection we created using custom SQL statement.

Remember to add ORDER BY <datapill> ASC

If you want to join your array with another data set, it’s totally possible with Collection too. You can read more on Collection here.

And with that, your array/list will be sorted.

--

--

Responses (1)