public static <T, U extends Comparable<? super U>> Comparator<T> comparing (Function<? super T, ? extends U> keyExtractor)

Accepts a function that extracts a Comparable sort key from a type T, and returns a Comparator<T> that compares by that sort key.

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

<T>    the type of element to be compared
<U>    the type of the Comparable sort key
keyExtractor    the function used to extract the Comparable sort key

Returns:  a comparator that compares by an extracted key

NullPointerException    if the argument is null

Since:  1.8

@apiNote For example, to obtain a Comparator that compares Person objects by their last name,

     Comparator<Person> byLastName = Comparator.comparing(Person::getLastName);