KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to sort my HashMap according to the values stored in it. The HashMap contains the contacts name stored in phone. Also I need that the keys get automatically sorted as soon as I sort the values, or you can say the keys and values are bound together thus any changes in values should get reflected in keys. HashMap<Integer,String> map = new HashMap<Integer,String>(); map.put(1,"froyo"); map.put(2,"abby"); map.put(3,"denver"); map.put(4,"frost"); map.put(5,"daisy"); Required output: 2,abby; 5,daisy; 3,denver; 4,frost; 1,froyo;
Tags (comma-separated)
Save Edits
Cancel