Skip to main content
Hi is anyone got the solution to this sorting problem.

I am unable to do descending order sorting.

My requirement is I have map Of <Id,Name>  when user click on the link the map values need to sort either ascending or descending order

Example If the Map values contain

Map.put(id1,Name1);  

Map.put(id3,Name3);  

Map.put(id2,Name2);  

Map.put(id5,Name5);  

Map.put(id6,Name6);  

Map.put(id4,Name4);  

Result for ascending 

Map.put(id1,Name1);  

Map.put(id2,Name2);  

Map.put(id3,Name3);  

Map.put(id4,Name4);  

Map.put(id5,Name5);  

Map.put(id6,Name6); 

Result for desendoing\

Map.put(id6,Name6);  

Map.put(id5,Name5);  

Map.put(id4,Name4);  

Map.put(id3,Name3);  

Map.put(id2,Name2);  

Map.put(id1,Name1); 

I did use different methods to solve this but nothing is working me out. Please, anyone, help me out I need to solve this issue.

One ve page I need to display these values.

Thank you

Aruna
5 answers
  1. May 30, 2018, 8:08 PM
    getting errors there no addAll method in MAP. I did use putAll method but getting errors
0/9000