This question has already been answered:
- Sort map by java value 5 answers
Help, you need to sort the Map in reverse order of value (Value).
Map<String, Integer> map = new HashMap<>(); map.put("Text1", 0); map.put("Text2", 1); map.put("Text3", 2); map.put("Text4", 0); It is necessary that it is sorted as follows:
Key - Value: Text3 - 2 Text2 - 1 Text1 - 0 Text4 - 0 or
Text3 - 2 Text2 - 1 Text4 - 0 Text1 - 0