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