sort() function
2 つの値を受け入れるコンパレータfに従ってソートされた配列を返します。
Signature:
typescript
declare function sort(
f: (a: any, b: any) => unknown,
iterable: readonly [],
): any[];Example
ts
sort((a, b) => a > b, [3, 4, 1, 2, 5, 2]); // [1, 2, 2, 3, 4, 5]
sort((a, b) => a.localeCompare(b), "bcdaef"); // ["a", "b", "c", "d", "e", "f"]