then method

Comparator<T> then(
  1. Comparator<T> comparator
)

Combines this Comparator and the given comparator such that the latter is applied only when the former considered values equal.

myList.sort(compareBy((o) => o.firstProperty).then(naturalOrder))

Implementation

Comparator<T> then(Comparator<T> comparator) {
  int compareTo(T a, T b) {
    final res = this(a, b);
    return res != 0 ? res : comparator(a, b);
  }

  return compareTo;
}