List of utility methods to do Map Sort
List | sortSimilarityMapByValue(SortedMap sort Similarity Map By Value Set<Entry<String, Double>> entryOfMap = temp.entrySet(); List<Entry<String, Double>> entries = new ArrayList<Entry<String, Double>>(entryOfMap); Collections.sort(entries, new Comparator<Entry<String, Double>>() { @Override public int compare(Entry<String, Double> o1, Entry<String, Double> o2) { return o2.getValue().compareTo(o1.getValue()); }); ... |
Map | sortValue(Map Returns a version of the given Map sorted by its values. final int mult = (descending) ? -1 : 1; List<Map.Entry<K, V>> entries = new LinkedList<Map.Entry<K, V>>(toSort.entrySet()); Collections.sort(entries, new Comparator<Map.Entry<K, V>>() { @SuppressWarnings("unchecked") public int compare(Map.Entry<K, V> one, Map.Entry<K, V> two) { if (one == null) { if (two == null) { return 0; ... |
List | sortXLabels(Map sort X Labels Collection<String> values = xLabels.values(); List<String> labels = new ArrayList<String>(); labels.addAll(values); Collections.sort(labels); for (String label : labels) System.out.println(label); return labels; |
String | toSortedString(Map, ?> map) Converts the given Map into a String in which the entries of the map are sorted by key + "=" + value pairs. if (map != null) { List<String> entries = new LinkedList<String>(); for (Entry<?, ?> entry : map.entrySet()) { entries.add(entry.getKey() + "=" + entry.getValue()); Collections.sort(entries); StringBuffer sb = new StringBuffer(); sb.append('{'); ... |