Function composeComparators

  • Composes multiple comparators into a single new one. The new comparator will call them in order, if the current comparator defined the values as equal.

    Nullish values in the initial array of comparators will be removed, before creating the composed comparator.

    Example

    // compare by length. if equal in length, compare alphabetically
    const myStringComparator = composeComparators([byLength, localeCompare]);

    Type Parameters

    Type Parameters

    • T

    Parameters

    • comparators: (undefined | null | Comparator<T>)[]

      array of comparator functions

    Returns Comparator<T>

Generated using TypeDoc