sortWith
Sorts an array using multiple comparators in priority order.
The first comparator has highest priority. When it returns 0 (tie), the next comparator is used, and so on.
Usage
sortWith<T>(array: readonly T[], comparators: ReadonlyArray<(a: T, b: T) => number>)
Sorts an array using multiple comparators in priority order.
The first comparator has highest priority. When it returns 0 (tie), the next comparator is used, and so on.
Parameters
arrayreadonly T[]required
the source array.
comparatorsReadonlyArray<(a: T, b: T) => number>required
the comparators to apply in priority order.
Returns
a new array ordered by the supplied comparators. The input array is not mutated.