sort

Sorts arrays based on a key.

Syntax

sort(direction, key, array_1, array_2, …, array_n)

Argument

direction
The direction in which the arrays are sorted, 0 or 1.
  • 1 = descending
  • 0 = ascending
key
The key with which to sort the arrays.
array_1, array_2, …,array_n
A string or numerical array.

Example

Templex Expression Results
{a = {1, 2, 10, 7}{b = {1, 2, 3, 4}{sort(0, a, b)} 1, 2, 4, 3

Comments

This function can also take the two arguments, direction and array_1.
sort(0, {1, 5, 4, 2, 3})
returns
{1, 2, 3, 4, 5}