Creates a comparator that compares two values of type T, based on the selected value of type O and the given comparator. If no comparator is passed, the naturalOrder comparator will be used.
T
O
naturalOrder
const idComparator = compareBy(x => x.id, naturalOrder);[{ id: 1, name: 'JavaScript' }, { id: 0, name: 'TypeScript' }].sort(idComparator);
function to extract the comparable value
comparator for the extracted values, defaults to naturalOrder
Generated using TypeDoc
Creates a comparator that compares two values of type
T
, based on the selected value of typeO
and the given comparator. If no comparator is passed, thenaturalOrder
comparator will be used.Example