public static function sortedIterator(\Traversable $iterator, Comparator $comparator = null, $cloneItems = false)
    {
        return (new SortedIterator($iterator, $cloneItems))->setComparator($comparator);
    }
public static function sortedIterator(\Traversable $iterator, Comparator $comparator = null, $cloneItems = false)
    {
        return (new SortedIterator($iterator, $cloneItems))->setComparator($comparator);
    }
public static function sortedIterator ( \ Traversable $ iterator , Comparator $ comparator = null , $ cloneItems = false ) { return ( new SortedIterator ( $ iterator , $ cloneItems ) ) -> setComparator ( $ comparator ) ; }
Converts an iterator to a sorted iterator, based on a given Comparator.
Uses ComparableComparator by default.

@param \Traversable $iterator
The original iterator
@param Comparator $comparator
Comparator to be used for comparison. By default, the ComparableComparator will be used.
@param bool $cloneItems
clones the elements of $iterator, this is necessary for Iterators that return the same instance
in different states like the evil DirectoryIterator.
@return \SGH\Comparable\Tool\SortedIterator
Converts an iterator to a sorted iterator based on a given Comparator . Uses ComparableComparator by default .