Here you can find the source of sortDoubleMap(Map
public static List<Map.Entry<String, Double>> sortDoubleMap(Map<String, Double> map)
//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; public class Main { public static List<Map.Entry<String, Double>> sortDoubleMap(Map<String, Double> map) { List<Map.Entry<String, Double>> mapSorted = new ArrayList<Map.Entry<String, Double>>(map.entrySet()); Collections.sort(mapSorted, new Comparator<Map.Entry<String, Double>>() { public int compare(Map.Entry<String, Double> o1, Map.Entry<String, Double> o2) { return (o2.getValue()).compareTo(o1.getValue()); }// w ww.ja v a 2s . co m }); return mapSorted; } }