Possible Duplicate:
TreeMap sort by value
Please have a look at the following code
import java.util.HashMap;
import java.util.Map;
public class Mapper
{
Map mMap;
public Mapper()
{
mMap = new HashMap();
mMap.put("A",1);
mMap.put("B",2);
mMap.put("C",3);
mMap.put("D",4);
mMap.put("E",5);
mMap.put("F",6);
}
}
As you can see, the Map contains, 2 types of data. Now I need to sort it by value, great if possible to do in descending order, otherwise no issue, normal sort. But, you know something like following is not possible
Map<String, int> treeMap = new TreeMap<String, int>(mMap);
So, how can I sort this ? Please help.