I have a HashMap with objects of a class (obj1, obj2, obj3) as keys and java.util.Date (date1, date2, date3)as values. The HashMap is already sorted based on the values, i.e., based on the date objects. The key objects are having property called name.
obj1.name = "name1", obj2.name = "name2" etc.
Now, When the values of HashMap are same, i.e., when there are same dates as values, I need to check the name of the key object (obj.name) and sort the HashMap based on name propery of key object. Note that I need to sort based on the name property of key object only when the HasHMap has same date as values.
For example, I have the below HashMap
[obj1=Tue Jul 01 00:00:00 IST 2014,obj2=Thu Jul 03 00:00:00 IST 2014,obj3=Thu Jul 03 00:00:00 IST 2014,obj4=Sun Jul 06 00:00:00 IST 2014]
And the name property of each key object is
obj1.name = "B";
obj2.name = "D";
obj3.name = "A";
obj4.name = "C";
Then finally I need to sort the HashMap to get the keySet in the order [obj1,obj3,obj2,obj4], since keys obj2 and obj3 have same date values and hence to be sorted based on name property of key objects.