public static < K , V extends Comparable < V > > List < Entry < K , V > > sortByValue ( Map < K , V > map ) { List < Entry < K , V > > entries = new ArrayList <> ( map . entrySet ( ) ) ; entries . sort ( new ByValue <> ( ) ) ; return entries ; }
Sorts the provided Map by the value instead of by key like TreeMap does .