Java 8 Comparator’s sort order reversal method

preview_player
Показать описание
In this video tutorial I will explain you how to work with Java
8 Comparator’s sort order reversal method – reversed() using a
demo project
Below is the GitHub link to download source code:

Рекомендации по теме
Комментарии
Автор

Interesting and subtle, your comparator defines a partial sort order, where employees with the same name but different ages come together, with no specified ordering within these. The .reversed() method for the comparator reverses ordering on all the things that the comparator cared about, in this case names. In this case that prints out highest names first, the ages still come out in the same order for Martin. This is a subtle difference from reversing the whole results after sorting. If the comparator fully specified a sort order, with no ties possible, those two would be the same.

jvsnyc