I have a Map that has strings for both keys and values.
Data is like following:
\"question1\", \"1\" \"question9\", \"1\" \"que
Using the TreeMap you can sort the map.
TreeMap
Map map = new HashMap<>(); Map treeMap = new TreeMap<>(map); for (String str : treeMap.keySet()) { System.out.println(str); }