code: public static <K, V> List<Entry<K, V>> sortMapEntries(@NonNull final Map<K, V> map,
                                                           @NonNull final Comparator<Entry<K, V>> comparator
                                                          ) {
        return map.entrySet().stream().sorted(comparator).collect(Collectors.toList());
     }
docs: Sorts a <code>Map</code> using a given <code>Comparator</code>
  
  @param <K>        the type parameter
  @param <V>        the type parameter
  @param map        The map to sort
  @param comparator The compartor to use for sorting the map entries
  @return A <code>List</code> of <code>Entry</code> containing the map entries in sorted order.