code: public static <K extends Comparable<? super K>, V> Comparator<Entry<K, V>> mapEntryComparator(boolean sortByKey,
                                                                                                   boolean ascending
                                                                                                  ) {
        return new MapEntryComparator<>(sortByKey, ascending);
     }
docs: Creates a comparator for Map entries. Requires that the element being sorted on implements
  <code>Comparable</code>.
  
  @param <K>       the Key type
  @param <V>       the value type
  @param sortByKey True sort by key, False sort by value
  @param ascending True sort in ascending order, False in descending order
  @return A comparator for sorting map entries.