#orderBy
Returns the array in ascending order of a selected value.
#orderBy(array, @x: key)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
array |
path | array |
The source array. |
key |
lambda |
Selects the value to sort by. |
Returns
Section titled “Returns”array
Examples
Section titled “Examples”Sort by a property
Section titled “Sort by a property”{ "people": [ { "name": "b", "age": 30 }, { "name": "a", "age": 20 } ]}{ "result": "#orderBy($.people, @x: @x.age)"}{ "result": [ { "name": "a", "age": 20 }, { "name": "b", "age": 30 } ]}