javascript-collections-framework
    Preparing search index...

    Function thenComparing

    • Returns a comparator that applies first, then each of next in turn to break ties.

      The result is the first one that is not 0, returned unchanged; later comparators are not called once one result is not 0. When every result is 0, the result is 0.

      Time: O(k) for k comparators, plus at most one call of each per comparison.

      Type Parameters

      • T

      Parameters

      Returns Comparator<T>

      The combined comparator.

      TypeError when any argument is not a function.

      type Person = { last: string; first: string }
      const byName = thenComparing<Person>(
      comparing((p) => p.last),
      comparing((p) => p.first),
      )