compareBy<T> function

Comparator<T> compareBy<T>(
  1. Comparable selector(
    1. T
    )
)

Creates a comparator using the function to transform value to a Comparable instance for comparison.

Implementation

Comparator<T> compareBy<T>(Comparable Function(T) selector) {
  int compareTo(T a, T b) => selector(a).compareTo(selector(b));
  return compareTo;
}