public static < T > Iterator < T > sort ( Iterator < T > self , Comparator < ? super T > comparator ) { return sort ( ( Iterable < T > ) toList ( self ) , true , comparator ) . listIterator ( ) ; }
Sorts the given iterator items into a sorted iterator using the comparator . The original iterator will become exhausted of elements after completing this method call . A new iterator is produced that traverses the items in sorted order .