on<T> static method

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

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

Implementation

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