# thenComparingWith<U> method

Comparator<T> thenComparingWith<U>(

1. U keyExtractor(
   1. T
   ),
2. Comparator<U> keyComparator

)

Chains a comparator by extracting a key with `keyExtractor` and comparing it using the given `keyComparator`.

### Example

    final byNameLength = Comparator.comparing((s) => s.length);
    final thenByLastChar = byNameLength.thenComparingWith(
      (s) => s[s.length - 1],
      Comparator.naturalOrder(),
    );

    final names = ['Joe', 'Jim', 'Jon'];
    names.sort(thenByLastChar.compare);
    print(names); // [Jim, Jon, Joe]

## Implementation

    Comparator<T> thenComparingWith<U>(U Function(T) keyExtractor, Comparator<U> keyComparator) {
      return thenComparing(_ComparingComparator(keyExtractor, keyComparator));
    }