I have a
Multimap<Date,Invoice> multimap = ArrayListMultimap.create();
from guava. I was wondering how to SORT the the Date key in the multimap.
Currently, I'm doing this:
Iterator<Date> dateItr = multimap.keySet().iterator();
Set<Date> treeSet = new TreeSet<Date>(Collections.reverseOrder());
and later I loop through the treeSet iterator. Any idea how to avoid this circumvention?
Guava team member here.
Use TreeMultimap
, or if you need to map into List
s, use MultimapBuilder
:
return MultimapBuilder.treeKeys().arrayListValues().build()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With