Multi criteria sorting of a list of objects with Guava Ordering
问题 I have a class WHICH CANNOT implement comparable, but needs to be sorted based on 2 fields. How can I achieve this with Guava? Let's say the class is: class X { String stringValue; java.util.Date dateValue; } And I have a list of these: List<X> lotsOfX; I want to sort them based on the value field first and then based on dateValue descending within each 'group' of 'value' fields. What I have been doing so far is: List<X> sortedList = ImmutableList.copyOf(Ordering.natural().onResultOf