Returns a comparator for the reverse of comparator, or of natural order when it is omitted.
comparator
The result for (a, b) is comparator(b, a), returned unchanged.
(a, b)
comparator(b, a)
Time: O(1) plus one call of comparator per comparison.
Optional
The order to reverse; natural order when omitted.
The reversed comparator.
TypeError when comparator is given but is not a function (including null).
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] Copy
[1, 3, 2].sort(reverseOrder()) // [3, 2, 1]
Returns a comparator for the reverse of
comparator, or of natural order when it is omitted.The result for
(a, b)iscomparator(b, a), returned unchanged.Time: O(1) plus one call of
comparatorper comparison.