Executes Comparators in order and returns the first non-zero result.
Sort objects first by age and then by name
const personComparator = chain<Person>( mappingComparator(numberComparator)(p => p.age), mappingComparator(stringComparator)(p => p.name));const array: Person[] = [ { age: 1, name: "B" }, { age: 1, name: "A" }];array.sort(personComparator);console.log(array); // [{age:1, name:"A"}, {age:1, name:"B"}]
the result of the first Comparator that is not 0, or else 0
0
the Comparator value type
Rest
the Comparators to chain
Generated using TypeDoc
Executes Comparators in order and returns the first non-zero result.
Example
Sort objects first by age and then by name
Returns
the result of the first Comparator that is not
0, or else0