mapping<T, V> static method

Comparator<V> mapping<T, V>(
  1. Comparator<T> comparator,
  2. T mapper(
    1. V v
    )
)

Use if you already have a custom comparator you wish to use but your list needs some mapping to get to the comparator's type. I.e., creates a Comparator

Implementation

static Comparator<V> mapping<T, V>(
  Comparator<T> comparator,
  T Function(V v) mapper,
) {
  return (a, b) => comparator(mapper(a), mapper(b));
}