sortBy (Functional Programming) es-toolkit
Creates a function that sorts an array of objects in ascending order by one or more criteria. Use it with pipe.
Info
Usage
sortBy sorts an array of objects in ascending order. Each criterion is either an object key or a function that returns the value to compare. When two elements tie on a criterion, the next criterion breaks the tie. The sort is stable and does not mutate the input.
Parameters
criteriaArray<((item: T) => unknown) | keyof T>required
The object keys and/or selector functions used for comparison, applied in order.
Returns
A function that maps a readonly T[] to a new, sorted T[].
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.