@ NotNull public static < T , U > ComparatorCompat < T > comparing ( @ NotNull final Function < ? super T , ? extends U > keyExtractor , @ NotNull final Comparator < ? super U > keyComparator ) { Objects . requireNonNull ( keyExtractor ) ; Objects . requireNonNull ( keyComparator ) ; return new ComparatorCompat < T > ( new Comparator < T > ( ) { @ Override public int compare ( T t1 , T t2 ) { final U u1 = keyExtractor . apply ( t1 ) ; final U u2 = keyExtractor . apply ( t2 ) ; return keyComparator . compare ( u1 , u2 ) ; } } ) ; }
Returns a comparator that uses a function that extracts a sort key to be compared with the specified comparator .