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.
|the type of element to be compared|
| the type of the |
| the function used to extract the |
|if the argument is null|
For example, to obtain a
Comparator that compares
Person objects by their last name,
Comparator<Person> byLastName = Comparator.comparing(Person::getLastName);