Sort a list


Sorts a list using a formula that is evaluated for each item in the list. Returns the sorted list.

The formula should result to a comparable value (a text or a number) that is used to determine the order of the items. By default the items are sorted in ascending order. By providing the 3rd parameter you can choose the direction.

If multiple values have the same ordering value, their original order will be preserved.

Note that for text values, the ordering is case-sensitive. If you want a case-insensitive ordering, you may for example wrap your ordering formula with LOWERCASE function.

Function signature

ORDER(list: Array, sortingcriteria: Function, sortdirection: String = asc) => Array




List of items to sort

Sorting criteria

Formula evaluated for each item in the list, used to determine the ordering value for the item

Sort direction

Direction of the ordering. Use either "asc" meaning ascending order (smallest first) or "desc" meaning descending order (greatest first).


animals = [
"name": "dog",
"weight": 123
"name": "cat",
"weight": 48
"name": "rat",
"weight": 10
"name": "pig",
"weight": 123


Return value

ORDER(animals, item.weight)


ORDER(animals, item.weight, "desc")


ORDER<animal>(animals, animal.weight, "asc")