Android examples for java.util:Iterable
is Iterable Sorted
import java.util.Comparator; public class Main { private static <T extends Comparable> boolean isSorted(Iterable<T> iterable, Comparator<T> comparator) { T previous = null;/* www. j av a 2 s. c om*/ for (T t : iterable) { if (previous != null && comparator.compare(previous, t) < 0) return false; previous = t; } return true; } }