jeudi 13 août 2015

Timestamp based sorting for a nested Map

I have a nested Map being returned by the Guava Library's Table structure that is templated as follows:

Map<ComplexID1, Map<ComplexID2, MyObject>>

where ComplexID1 is my row key, ComplexID2 is my column key and MyObject holds my metadata. One of the attributes of my metadata is a JODA timestamp.

I need to sort this whole structure chronologically (or reverse chronologically) for display, newest objects created at the top, going backwards.

I was unable to find any information to sort this data structure. Could someone please provide some pointers?

Further, I tried to have the MyObject class extend Comparable and override CompareTo on the JODA datetime object because I was trying to use Collections.Sort(). Unfortunately, that approach does not seem to work for me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire