sort
sort() function
Returns an array, sorted according to the comparator f
, which should accept two values
Signature:
declare function sort(f: (a: any, b: any) => unknown, iterable: readonly []): any[];
Returns:
any[]
Example
sort((a, b) => a > b, [3, 4, 1, 2, 5, 2]); // [1, 2, 2, 3, 4, 5]
sort((a, b) => a > b, 'bcdaef); // ["a", "b", "c", "d", "e", "f"]