Java Map Sort sortDoubleMap(Map map)

Here you can find the source of sortDoubleMap(Map map)

Description

sort Double Map

License

Open Source License

Declaration

public static List<Map.Entry<String, Double>> sortDoubleMap(Map<String, Double> map) 

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;

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;
    }
}

Related

  1. sortByValues(Map map)
  2. sortByValues(Map map)
  3. sortByValues(Map map)
  4. sortByValuesDesc(final Map map)
  5. sortClustersKeys(final Map> clusters)
  6. sortedByRankThenLength(Map map)
  7. sortedKeys(Map map)
  8. sortedMap(Map map, Comparator comparator)
  9. sortedString(Map c)