#orderByDesc
Returns the array in descending order of a selected value.
#orderByDesc(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, descending
Section titled “Sort by a property, descending”{ "people": [ { "name": "a", "age": 20 }, { "name": "b", "age": 30 } ]}{ "result": "#orderByDesc($.people, @x: @x.age)"}{ "result": [ { "name": "b", "age": 30 }, { "name": "a", "age": 20 } ]}