Java Utililty Methods Map Sort

List of utility methods to do Map Sort

Description

The list of methods to do Map Sort are organized into topic(s).

Method

List>sortSimilarityMapByValue(SortedMap temp)
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());
});
...
MapsortValue(Map toSort, boolean descending, final boolean thenByKey)
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;
...
ListsortXLabels(Map xLabels)
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;
StringtoSortedString(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('{');
...