Java tutorial
//package com.java2s; import java.util.*; public class Main { /** * From http://stackoverflow.com/questions/3047051/how-to-determine-if-a-list-is-sorted-in-java * @param iterable * @param <T> * @return */ public static <T extends Comparable<? super T>> boolean isSorted(Iterable<T> iterable) { Iterator<T> iter = iterable.iterator(); if (!iter.hasNext()) { return true; } T t = iter.next(); while (iter.hasNext()) { T t2 = iter.next(); if (t.compareTo(t2) > 0) { return false; } t = t2; } return true; } }