Skip to content
HTTP & JSON jsonArraySort

$jsonArraySort[]

$jsonArraySort sorts the elements of a JSON array in-place. The default order is ascending (‘asc’). For alphabetical sorting, strings are compared lexicographically. For numerical sorting, values are compared as numbers. To get descending order, either pass ‘desc’ or sort ascending and then reverse with $jsonArrayReverse.

Syntax

bdfd
$jsonArraySort[key;order?]

Examples

Sort Elements in JSON Array

$jsonParse[{"scores":[50,10,95,30]}]
$jsonArraySort[scores]
$title[Sorted Scores]
$description[Sorted ascending: `$jsonStringify`]
$color[#5865F2]
$sendMessage[]