sort

Sort an array in ascending order

Definition

array sort(array[number]|array[string] $list)

Sorts input in ascending order, or alphabetically when sorting strings.

Parameters

array[number]|array[string] $list

The array to be sorted.

Returns

array

Input array, sorted ascending, alphabetically.

Examples

{
  a: sort(['beta', 'gamma', 'alpha']),
  b: sort(['gamma', 'beta', '1']),
  c: sort(`[3, 1.5, 0, 7, -3]`),
  d: sort([`false`, `[]`, `null`, `true`, 'A', 'a'])
}
{
  "a": ["alpha", "beta", "gamma"],
  "b": ["1", "beta", "gamma"],
  "c": [-3, 0, 1.5, 3, 7],
  "d": null
}