I want to sort HashMap < String[], Boolean > in ascending order. It works fine with this code which I have written
//HashMap<String[], Boolean> literalTable = new HashMap<>(); // declared some where in my code
ArrayList<String[]> arrayList = new ArrayList<>();
for (int i = 0; i < literalTable.size(); ++i){
String[] str = {};
arrayList.add(str);
}
for (Map.Entry m: literalTable.entrySet()){
String[] str = (String[]) m.getKey();
Integer index = Integer.parseInt(str[0]);
arrayList.set(index, str);
}
arrayList.sort(Comparator.comparing(p -> p[0]));
My question is, is there any sort way to do the same task? I Googled it and found one solution, it says that you can use TreeMap but it's not working as well.