guava/src/com/google/common/collect/Comparators.java
@Beta
  public static <T> Comparator<Optional<T>> emptiesLast(Comparator<? super T> valueComparator) {
    checkNotNull(valueComparator);
    return Comparator.comparing(o -> o.orElse(null), Comparator.nullsLast(valueComparator));
  }
@Beta
  public static <T> Comparator<Optional<T>> emptiesLast(Comparator<? super T> valueComparator) {
    checkNotNull(valueComparator);
    return Comparator.comparing(o -> o.orElse(null), Comparator.nullsLast(valueComparator));
  }
Returns a comparator of {@link Optional} values which treats {@link Optional#empty} as greater
than all other values, and orders the rest using {@code valueComparator} on the contained
value.

@since 22.0