Articles in this section

sort helper

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:

Usage

{{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.

Examples

  1. Ascending numeric sort

    {{sort record.items number="true"}}
    

    If record.items is ["2","1","4","5","3"], this outputs 1,2,3,4,5.

  2. Descending numeric sort

    {{sort record.items number="true" reverse="true"}}
    

    Using the same array, this produces 5,4,3,2,1.

  3. Sorting strings in ascending order

    {{sort record.items}}
    

    If record.items is ["candy","hat","toy"], it sorts to candy,hat,toy.

  4. 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", use number="true" to avoid alphabetical ordering ("10","2") instead of the desired numeric order (2,10).

  • Combining number="true" with reverse="true" yields a descending numeric sort.

  • Consider whether you need raw output ({{{ }}}) or default formatting ({{ }}}) when working with sorted data.