public default Comparator<T> thenComparing (Comparator<? super T> other)

Returns a lexicographic-order comparator with another comparator. If this Comparator considers two elements equal, i.e. compare(a, b) == 0, other is used to determine the order.

The returned comparator is serializable if the specified comparator is also serializable.

Parameters:
other    the other comparator to be used when this comparator compares two objects that are equal.

Returns:  a lexicographic-order comparator composed of this and then the other comparator

Exceptions:
NullPointerException    if the argument is null.

Since:  1.8

@apiNote For example, to sort a collection of String based on the length and then case-insensitive natural ordering, the comparator can be composed using following code,


     Comparator<String> cmp = Comparator.comparingInt(String::length)
             .thenComparing(String.CASE_INSENSITIVE_ORDER);