Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Tag: sort

Digital Innovation Partner

Sorting a Java Map

Hi, a short post to show a simple tip useful when dealing with Java Maps. The following Function sorts a Map through a custom Comparator and returns a new ordered LinkedHashMap: public static Map sortMapByKey(Map map, Comparator comparator) { List list = new LinkedList(map.keySet()); Collections.sort(list, comparator); Map result = new LinkedHashMap(); for (Object o :…
Leggi tutto