Here you can find the source of mapTosortedScoreList(HashMap
Parameter | Description |
---|---|
unSortedMap | a parameter |
public static LinkedList<Entry<Long, Double>> mapTosortedScoreList(HashMap<Long, Double> unSortedMap)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; public class Main { /** This function creates a sorted list using the maps * @param unSortedMap/* w w w .ja v a 2s . c om*/ * @return */ public static LinkedList<Entry<Long, Double>> mapTosortedScoreList(HashMap<Long, Double> unSortedMap) { LinkedList<Entry<Long, Double>> mapList = new LinkedList<Entry<Long, Double>>(unSortedMap.entrySet()); Collections.sort(mapList, new Comparator<Entry<Long, Double>>() { @Override public int compare(Entry<Long, Double> o1, Entry<Long, Double> o2) { // TODO Auto-generated method stub return o2.getValue().compareTo(o1.getValue()); } }); return mapList; } }