on<T> static method

Comparator<T> on<T>(
  1. Comparable mapper(
    1. T t
    )
)

Returns a Comparator that compares objects of type T by mapping then to Comparables.

Implementation

static Comparator<T> on<T>(Comparable Function(T t) mapper) {
  return (a, b) => mapper(a).compareTo(mapper(b));
}