Here you can find the source of isSort(Collection
public static <E extends Comparable<E>> boolean isSort(Collection<E> c)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { public static <E extends Comparable<E>> boolean isSort(Collection<E> c) { E pointer = null, next;//from w w w .j a v a 2 s .com Iterator<E> it = c.iterator(); if (it.hasNext()) pointer = it.next(); while (it.hasNext()) { next = it.next(); if (pointer.compareTo(next) > 0) return false; pointer = next; } return true; } }