code: public static boolean hasSameComparator(Comparator<?> comparator, Iterable<?> elements) {
      checkNotNull(comparator);
      checkNotNull(elements);
      Comparator<?> comparator2;
      if (elements instanceof SortedSet) {
        comparator2 = comparator((SortedSet<?>) elements);
      } else if (elements instanceof SortedIterable) {
        comparator2 = ((SortedIterable<?>) elements).comparator();
      } else {
        return false;
      }
      return comparator.equals(comparator2);
    }
docs: Returns {@code true} if {@code elements} is a sorted collection using an ordering equivalent
  to {@code comparator}.