android/guava/src/com/google/common/collect/Iterables.java
@Beta
  public static <T> Iterable<T> mergeSorted(
      final Iterable<? extends Iterable<? extends T>> iterables,
      final Comparator<? super T> comparator) {
    checkNotNull(iterables, "iterables");
    checkNotNull(comparator, "comparator");
    Iterable<T> iterable =
        new FluentIterable<T>() {
          @Override
          public Iterator<T> iterator() {
            return Iterators.mergeSorted(
                Iterables.transform(iterables, Iterables.<T>toIterator()), comparator);
          }
        };
    return new UnmodifiableIterable<>(iterable);
  }
@Beta
  public static <T> Iterable<T> mergeSorted(
      final Iterable<? extends Iterable<? extends T>> iterables,
      final Comparator<? super T> comparator) {
    checkNotNull(iterables, "iterables");
    checkNotNull(comparator, "comparator");
    Iterable<T> iterable =
        new FluentIterable<T>() {
          @Override
          public Iterator<T> iterator() {
            return Iterators.mergeSorted(
                Iterables.transform(iterables, Iterables.<T>toIterator()), comparator);
          }
        };
    return new UnmodifiableIterable<>(iterable);
  }
@ Beta public static < T > Iterable < T > mergeSorted ( final Iterable < ? extends Iterable < ? extends T > > iterables , final Comparator < ? super T > comparator ) { checkNotNull ( iterables , "iterables" ) ; checkNotNull ( comparator , "comparator" ) ; Iterable < T > iterable = new FluentIterable < T > ( ) { @ Override public Iterator < T > iterator ( ) { return Iterators . mergeSorted ( Iterables . transform ( iterables , Iterables . < T > toIterator ( ) ) , comparator ) ; } } ; return new UnmodifiableIterable <> ( iterable ) ; }
Returns an iterable over the merged contents of all given {@code iterables}. Equivalent entries
will not be de-duplicated.

<p>Callers must ensure that the source {@code iterables} are in non-descending order as this
method does not sort its input.

<p>For any equivalent elements across all {@code iterables}, it is undefined which element is
returned first.

@since 11.0
Returns an iterable over the merged contents of all given { @code iterables } . Equivalent entries will not be de - duplicated .