Use the sort helper to arrange an array’s items in ascending or descending order. By default, the items are sorted alphabetically (lexicographically) in ascending order. You can enable numeric sorting or reverse the sort order using optional parameters:
{{sort field [number="true"] [reverse="true"]}}
-
field: The field or variable containing an array to sort (e.g.,
record.items). -
number (optional): If set to
"true", the items are sorted numerically instead of lexicographically. -
reverse (optional): If set to
"true", sorts in descending order.
-
Ascending numeric sort
{{sort record.items number="true"}}If
record.itemsis["2","1","4","5","3"], this outputs1,2,3,4,5. -
Descending numeric sort
{{sort record.items number="true" reverse="true"}}Using the same array, this produces
5,4,3,2,1. -
Sorting strings in ascending order
{{sort record.items}}If
record.itemsis["candy","hat","toy"], it sorts tocandy,hat,toy. -
Using triple braces for raw output
{{{sort record.items}}}Returns the same sorted result, but without Celigo’s automatic wrapping or encoding (for example, quotes around the output).
Tip
-
If your array contains numeric strings like
"10"and"2", usenumber="true"to avoid alphabetical ordering ("10","2") instead of the desired numeric order (2,10). -
Combining
number="true"withreverse="true"yields a descending numeric sort. -
Consider whether you need raw output (
{{{ }}}) or default formatting ({{ }}}) when working with sorted data.