public static <K,V extends Comparable<V>>List<Entry<K,V>> sortByValue(Map<K,V> map){
  List<Entry<K,V>> entries=new ArrayList<Entry<K,V>>(map.entrySet());
  Collections.sort(entries,new ByValue<K,V>());
  return entries;
}

public static < K , V extends Comparable < V > > List < Entry < K , V > > sortByValue ( Map < K , V > map ) { List < Entry < K , V > > entries = new ArrayList < Entry < K , V > > ( map . entrySet ( ) ) ; Collections . sort ( entries , new ByValue < K , V > ( ) ) ; return entries ; }
generic method to sort a map by value
