Have one class
class Employee {
    int id;
    String name;
}
and one map which contains this object in value
Map<Integer, Employee> map = new HashMap<Integer, Employee>();
Now I want to sort above map one the basis of Employee's name. Means when I iterate this map using Map.Entry, Employee objects must retrive alphabetically.
Thanks in advance
Use a TreeMap with a custom Comparator using this constructor:
http://docs.oracle.com/javase/6/docs/api/java/util/TreeMap.html#TreeMap(java.util.Comparator)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With