javascript-collections-framework
    Preparing search index...

    Function reverseOrder

    • Returns a comparator for the reverse of comparator, or of natural order when it is omitted.

      The result for (a, b) is comparator(b, a), returned unchanged.

      Time: O(1) plus one call of comparator per comparison.

      Type Parameters

      • T

      Parameters

      • Optionalcomparator: Comparator<T>

        The order to reverse; natural order when omitted.

      Returns Comparator<T>

      The reversed comparator.

      TypeError when comparator is given but is not a function (including null).

      NullElementError, ClassCastError or TypeError (from the comparator, when natural order is used) as described for naturalOrder.

      [1, 3, 2].sort(reverseOrder()) // [3, 2, 1]