reverse<T> static method

Comparator<T> reverse<T>(
  1. Comparator<T> comparator
)

Reverses a given comparator, that is, change it from ascending to descending or vice-versa.

Implementation

static Comparator<T> reverse<T>(Comparator<T> comparator) {
  return (a, b) => -comparator(a, b);
}