code: public static <K extends Comparable<K>, V extends Comparable<V>> List<Map.Entry<K, V>> sortByValueAndKey(Map<K, V> map) {
          List<Map.Entry<K, V>> entries = new ArrayList<>(map.entrySet());
          entries.sort(new ByValueAndKey<>());
          return entries;
      }
docs: Sorts the provided Map by the value and then by key instead of by key like TreeMap does.
  
  The Value-Type and Key-Type need 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 Needs to derive from {@link Comparable}
  @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 first and then by Key.
  
  
  @return Returns a new List of Map.Entry values sorted by value and key.