package com.alexrnl.commons.utils;

import java.util.Iterator;
import java.util.Objects;
import java.util.logging.Logger;

/**
 * Utilities on collections.<br />
 * @author Alex
 */
public final class CollectionUtils {
	/** Logger */
	private static Logger	lg	= Logger.getLogger(CollectionUtils.class.getName());
	
	/**
	 * Constructor #1.<br />
	 * Default private constructor.
	 */
	private CollectionUtils () {
		super();
	}
	
	/**
	 * Check if a collection is sorted.<br />
	 * @param collection
	 *        the collection to check.
	 * @return <code>true</code> if the collection is sorted.
	 */
	public static <T extends Comparable<? super T>> boolean isSorted (final Iterable<T> collection) {
		Objects.requireNonNull(collection);
		final Iterator<T> it = collection.iterator();
		
		while (it.hasNext()) {
			final T current = it.next();
			if (it.hasNext() && current.compareTo(it.next()) > 0) {
				return false;
			}
		}
		
		return true;
	}
}

@@ -82,16 +82,48 @@
 bjects;%0A
+import java.util.logging.Level;%0A
 import j
@@ -929,16 +929,122 @@
  %3E 0) %7B%0A
+%09%09%09%09if (lg.isLoggable(Level.INFO)) %7B%0A%09%09%09%09%09lg.info(%22Collection is unordered at element %22 + current);%0A%09%09%09%09%7D%0A
 %09%09%09%09retu

Use logger is method isSorted