Java Map Sort sortSimilarityMapByValue(SortedMap temp)

Here you can find the source of sortSimilarityMapByValue(SortedMap temp)

Description

sort Similarity Map By Value

License

Open Source License

Declaration

public static List<Entry<String, Double>> sortSimilarityMapByValue(SortedMap<String, Double> temp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Collections;
import java.util.Comparator;

import java.util.List;

import java.util.Map.Entry;

import java.util.Set;
import java.util.SortedMap;

public class Main {
    public static List<Entry<String, Double>> sortSimilarityMapByValue(SortedMap<String, Double> temp) {
        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/*from w w w .  jav a 2s.  c om*/
            public int compare(Entry<String, Double> o1, Entry<String, Double> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });
        return entries;
    }
}

Related

  1. sortMapDesc(Map map)
  2. sortMapDescByValue(Map map)
  3. sortMapDescendingByValue(Map unsortedMap)
  4. sortMapUsingComparator(final Map map, final Comparator comparator)
  5. sortParams(Map params)
  6. sortValue(Map toSort, boolean descending, final boolean thenByKey)
  7. sortXLabels(Map xLabels)
  8. toSortedString(Map map)