@metreeca/core - v0.9.11
    Preparing search index...

    Function by

    • Creates a comparator that compares values by a selected key.

      Extracts a comparable key from each value using the selector function, then applies the specified comparator to the keys.

      Type Parameters

      • V

        The type of values to compare

      • K

        The type of keys to compare

      Parameters

      • selector: (value: V) => K

        Function that extracts the comparison key from a value

      • comparator: (a: K, b: K) => number = ascending

        Comparator to apply to the extracted keys (defaults to ascending)

      Returns (a: V, b: V) => number

      A comparator function that compares values by their selected keys