I have a HashMap
of arrays of strings identified by integers as key. I want to sort this HashMap by keys.
My hashmap : HashMap<Integer, String[]> htab = new HashMap<>();
I tried the TreeMap
solution but it doesn't have a compatible constructor of my values (String[]
):
Map<Integer, String> map = new TreeMap<Integer, String>((Comparator<? super Integer>) htab);
Example of a set of my HashMap:
21 : {"2","3","5","10","0"}