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:
c
I suspect you want Ordering.compound. You could do it all in one statement, but I'd use:
Ordering primary = Ordering.natural().onResultOf(stringValueSortFunction);
Ordering secondary = Ordering.natural()
.onResultOf(dateValueSortFunction)
.reverse();
Ordering compound = primary.compound(secondary);
List sortedList = compound.immutableSortedCopy(lotsOfX);