In a Java class I have a method to reOrder an existing HashMap by date. The HashMap is of a type
where the Object contains a field called exp
Get all Entries by calling entrySet()
method of Map
Create a custom Comparator
to sort entries based upon values
Convert Entry
set to List
Sort Entry list by using Collections.sort()
method by passing your value comparator
Create a LinkedHashMap
by adding entries in sorted order.
Look at example code @ Sort HasMap by value