If you want to use TreeMap and customize the order, then you have two options:
Write your own Comparator and pass it to the constructor of TreeMap.Make the class that you use for the keys implement interface Comparable, and add the appropriate compareTo() method to your key class.
If you are using normal Strings as the keys, then the second isn't going to work, because you can't change the implementation of class
String.