Java SortedSet entriesSortedByValues( Map map)

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

Description

entries Sorted By Values

License

Open Source License

Declaration

public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
            Map<K, V> map) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Comparator;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
    public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
            Map<K, V> map) {
        SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(new Comparator<Map.Entry<K, V>>() {
            @Override//  w ww  .  j a  v a  2 s .  c o m
            public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
                return e1.getValue().compareTo(e2.getValue());
            }
        });
        sortedEntries.addAll(map.entrySet());
        return sortedEntries;
    }
}

Related

  1. asSortedSet(T... elements)
  2. computeGraphCauselessFromGraphLmms( List>>> causesByDepByNameList)
  3. computeGraphCauselessFromGraphMms( SortedMap>> causesByDepByName)
  4. copyAndClearSet(SortedSet sourceSet)
  5. doubleForDescreteStartAndEnds(SortedSet hours)
  6. fillOutHourly(SortedSet hours)
  7. getEntryOrEmptySet(K key, Map> map)
  8. getFlatItems(Map> linkedWorkItemIDsMap)
  9. getSortedIntersectionValues(Collection colection1, Collection colection2)