code: 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;
      }
docs: Sorts the provided Map by the value instead of by key like TreeMap does.
  
  The Value-Type needs to implement the Comparable-interface.
  
  Note: this will require one Map.Entry for each element in the Map, so for very large
  Maps this will incur some memory overhead but will not fully duplicate the contents of the map.
  
  @param <K> the key-type of the Map that should be sorted
  @param <V> the value-type of the Map that should be sorted. Needs to derive from {@link Comparable}
  
  @param map A map with some elements which should be sorted by Value.
  
  
  @return Returns a new List of Map.Entry values sorted by value.