HashMap<String,Integer> h = someCodeToMakeTheHash(); ArrayList<Integer> vals = new ArrayList<Integer>(h.values()); Collections.sort(vals);h.values() gives as HashSet.
Programming Tips - Java: How can I convert a HashMap's values into a sorted ArrayList?
Date: 2016mar9
Language: Java
Keywords: to
Q. Java: How can I convert a HashMap's values into a sorted ArrayList?
A. ArrayList's constructor takes a HashSet so its pretty easy: