Skip to content

#orderByDesc

Returns the array in descending order of a selected value.

#orderByDesc(array, @x: key)
Category Arrays and sequencesValid in Property value
Name Type Description
array path | array The source array.
key lambda Selects the value to sort by.

array

source.json
{
"people": [ { "name": "a", "age": 20 }, { "name": "b", "age": 30 } ]
}
transformer.json
{
"result": "#orderByDesc($.people, @x: @x.age)"
}
output.json
{
"result": [ { "name": "b", "age": 30 }, { "name": "a", "age": 20 } ]
}

Try it in the playground →

#orderBy