createComparatorBy
createComparatorBy<
T>(…valueOfs):Comparator<T>
Defined in: packages/core/src/function/compare/create-comparator.ts:40
Builds a Comparator ordering items by one or more derived keys, each in ascending natural order, earlier keys taking priority over later ones.
Variadic rather than a traits object because the keys are homogeneous and
their order is the priority; named fields would lose it.
For a key that needs its own ordering — descending, or anything but natural —
compose instead: createChainedComparator(createComparatorBy(keyOf), createReversedComparator(createComparatorBy(otherKeyOf))).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”valueOfs
Section titled “valueOfs”…readonly [Callable<[T], unknown>, Callable<[T], unknown>]
Key accessors, in priority order. At least one is required.
Returns
Section titled “Returns”Comparator<T>
A comparator calling one accessor per operand per key, at worst.