@sort
Sort an array using a comparator helper.
Returns: array
Syntax
Section titled “Syntax”@sort(arr fn)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
arr |
array |
Source array |
fn |
helper |
Comparator helper returning a number |
Examples
Section titled “Examples”# Sort ascendingdef @cmpAsc "$a: number $b: number -> number" @num($a - $b)set $nums [3 1 4 1 5]set $sorted @sort($nums @cmpAsc)See Also
Section titled “See Also”- @reverse — reverse an array