Here you can find the source of sortSimilarityMapByValue(SortedMap
public static List<Entry<String, Double>> sortSimilarityMapByValue(SortedMap<String, Double> temp)
//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; } }