Java tutorial
import java.util.HashMap; import java.util.Map; import java.util.TreeMap; public class Main { public static void main(String[] args) { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("4", "four"); hm.put("3", "three"); hm.put("1", "one"); hm.put("2", "two"); Map<String, String> treeMap = new TreeMap<String, String>(hm); System.out.println(treeMap); } }