join<T> static method

Comparator<T> join<T>(
  1. List<Comparable Function(T t)> mappers
)

Join several mappers and compare in order (first the first element, then the second, and so on).

Implementation

static Comparator<T> join<T>(List<Comparable Function(T t)> mappers) {
  return (a, b) {
    final r = on(mappers.first)(a, b);
    if (r == 0) {
      if (mappers.length == 1) {
        return 0;
      }
      return join(mappers.sublist(1))(a, b);
    } else {
      return r;
    }
  };
}