guava/src/com/google/common/collect/ImmutableSortedSet.java
public static <E> ImmutableSortedSet<E> copyOf(
      Comparator<? super E> comparator, Collection<? extends E> elements) {
    return copyOf(comparator, (Iterable<? extends E>) elements);
  }
public static <E> ImmutableSortedSet<E> copyOf(
      Comparator<? super E> comparator, Collection<? extends E> elements) {
    return copyOf(comparator, (Iterable<? extends E>) elements);
  }
Returns an immutable sorted set containing the given elements sorted by the given {@code
Comparator}. When multiple elements are equivalent according to {@code compareTo()}, only the
first one specified is included.

<p>Despite the method name, this method attempts to avoid actually copying the data when it is
safe to do so. The exact circumstances under which a copy will or will not be performed are
undocumented and subject to change.

<p>This method is safe to use even when {@code elements} is a synchronized or concurrent
collection that is currently being modified by another thread.

@throws NullPointerException if {@code comparator} or any of {@code elements} is null
@since 7.0 (source-compatible since 2.0)