public static HashMap<String, Double> sortByValue(HashMap<String, Double> map) {
        List<Map.Entry<String, Double>> list = new LinkedList<Map.Entry<String, Double>>(map.entrySet());

        Collections.sort(list, new Comparator<Map.Entry<String, Double>>() {
        
            public int compare(Map.Entry<String, Double> m1, Map.Entry<String, Double> m2) {
            	int out = 0;
            	if (m2.getValue() < m1.getValue()){
            		out = -1;
            	}
               	if (m2.getValue() > m1.getValue()){
               		out = 1;
            	}
               	if (m2.getValue() == m1.getValue()){
               		out = 0;
               	}
               	return out;
            }
      	});

        HashMap<String, Double> result = new LinkedHashMap<String, Double>();
        for (Map.Entry<String, Double> entry : list) {
            result.put(entry.getKey(), entry.getValue());
        }
        return result;
    }