code: public static <T> SerializableComparator<T> comparator(T item) {
        if ((item != null && item instanceof Comparable)) {
           return Sorting::compare;
        }
        return Sorting.hashCodeComparator();
     }
docs: Creates a comparator by examining an item. If the item is of type Comparable (i.e. is not null and implements the
  Comparable interface), a comparator is returned that uses the Comparable method. Otherwise a hashcode based
  comparator is returned.
  
  @param <T>  The type of the comparator
  @param item An example item to help and determine the best comparator
  @return A Comparator