Derives the value to compare.
Optionalcomparator: Comparator<U>
Orders the keys; natural order when omitted.
The comparator.
NullElementError, ClassCastError or TypeError (from the comparator, when natural order is used) as described for naturalOrder.
Returns a comparator that orders values by a key derived from each of them.
keyis called exactly once for each of the two values in every comparison, and its errors propagate. The keys are compared withcomparator, or in natural order when it is omitted (so keys of mixed kinds throwClassCastError). Wrap the key comparator with nullsFirst or nullsLast to allow missing keys.Time: O(1) plus two calls of
keyand one ofcomparatorper comparison.