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
Your best bet will be to use a SortedMap with the Comparator interface.
Here is an example:
public SortedMap getSortedMap(Map originalMap) {
SortedMap tmpMap = new TreeMap(new Comparator(){
@Override
public int compare(String key1, String key2) {
//logic for comparing dates
}
});
tmpMap.putAll(originalMap);
return tmpMap;
}