O'Reilly logo
  • You Wang thinks this is interesting:

The static comparing method takes a “key extractor” function that maps a type T to a comparable type (such as String). The function is applied to the objects to be compared, and the comparison is then made on the returned keys. For example, suppose you have an array of Person objects. Here is how you can sort them by name:

From

Cover of Core Java® Volume I—Fundamentals, Tenth Edition

Note

This reduces the need of hand writing a comparing function.