Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 5x 6x | import { Comparator } from "./_types";
/**
* A {@link Comparator} that orders `boolean` values by their natural order,
* i.e. `false < true`.
*
* @example
* Sort an Array of boolean values
* ```ts
* const array = [true, false, true];
* array.sort(booleanComparator);
* console.log(array); // [false, true, true]
* ```
*
* @param booleanA - the first boolean value
* @param booleanB - the second boolean value
* @returns a {@link Comparator} for boolean values
*/
export const booleanComparator: Comparator<boolean> = (booleanA, booleanB) => {
return booleanA === booleanB ? 0 : booleanA ? 1 : -1;
};
|