public static < T extends Comparable < ? super T > > Iterator < T > getSortedIterator ( Iterable < T > coll ) { return getSortedIterator ( coll . iterator ( ) , new Comparator < T > ( ) { public int compare ( T o1 , T o2 ) { if ( o1 == o2 ) { // catches null == null return 0 ; } else if ( o1 == null ) { return 1 ; } else if ( o2 == null ) { return - 1 ; } return o1 . compareTo ( o2 ) ; // null-free } } ) ; }
Get an Iterator over the supplied Collection that returns the elements in their natural order .