by<T> static method
Returns a Comparator that compares two T
s 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));