by<T> static method

  1. @useResult
Comparator<T> by<T>(
  1. Select<T, Comparable<Object>> select
)

Returns a Comparator that compares two Ts using the values produced by select.

final compare = Comparators.by<(String, int)>((e) => e.$2);
compare(('b', 1), MapEntry('a', 2)); // -1

Implementation

@useResult static Comparator<T> by<T>(Select<T, Comparable<Object>> select) => (a, b) => select(a).compareTo(select(b));