sort

Sorts the elements of an array.

sort

Sorts the elements of an array.

Type: transform

Aliases

arraySort, order, sort

Parameters

  • input (array): The input array to sort.
  • expression (string?): Optional JEXL expression to determine sort value for objects.
  • descending (boolean?): Optional flag to sort in descending order.

Returns

Type: array

A new sorted array, or empty array if input is not an array.

Examples

sort([3, 1, 2]) // [1, 2, 3]
[3, 1, 2]|sort // [1, 2, 3]
sort([{age: 30}, {age: 20}], "age") // [{age: 20}, {age: 30}]
Cookie Notice

We use cookies to enhance your browsing experience.