compare and sort functions added to runtime
compare
two numbers or two strings to determine if they are equal (0), a > b (1) or b > a (-1)sort
an array using an optional function predicate for example:
Field-based sort
let data = [{'x': 6}, {'x': 1}, {'x': 3}]
let sorted = $sort($data, fn ($a, $b) { $compare($a.x, $b.x) });
Common case
let data = [6, 1, 3]
let sorted = $sort($data, $compare); // where compare takes strings or numbers
...or simply omit the $compare
predicate to take advantage of builtin Array.sort
behaviour