code: @Nonnull
      public static <T extends Comparable<T>> List<T> sortOptionallyComparables(@Nonnull Collection<T> toReturn) {
          List<T> list = new ArrayList<>(toReturn);
          try {
              Collections.sort(list);
          } catch (IllegalArgumentException e) {
              // catch possible sorting misbehaviour
              if (!e.getMessage().contains("Comparison method violates its general contract!")) {
                  throw e;
              }
              // otherwise print a warning and leave the list unsorted
          }
          return list;
      }
docs: Sort a copy of the input collection; if the ordering is unstable and an
  error is thrown (due to the use of TimSort in JDK 1.7 and newer), catch
  it and leave the collection unsorted. NOTE: use this method if ordering
  is desirable but not necessary.
  
  @param toReturn
  collection to sort
  @param <T>
  list type
  @return sorted copy of the input, if no errors are raised. Copy of the
  original otherwise.