protected function buildOrderBy(Iterator $iterator): Iterator
    {
        if ([] === $this->order_by) {
            return $iterator;
        }

        $compare = function (array $record_a, array $record_b): int {
            foreach ($this->order_by as $callable) {
                if (0 !== ($cmp = $callable($record_a, $record_b))) {
                    return $cmp;
                }
            }

            return $cmp ?? 0;
        };

        $iterator = new ArrayIterator(iterator_to_array($iterator));
        $iterator->uasort($compare);

        return $iterator;
    }
protected function buildOrderBy(Iterator $iterator): Iterator
    {
        if ([] === $this->order_by) {
            return $iterator;
        }

        $compare = function (array $record_a, array $record_b): int {
            foreach ($this->order_by as $callable) {
                if (0 !== ($cmp = $callable($record_a, $record_b))) {
                    return $cmp;
                }
            }

            return $cmp ?? 0;
        };

        $iterator = new ArrayIterator(iterator_to_array($iterator));
        $iterator->uasort($compare);

        return $iterator;
    }
protected function buildOrderBy ( Iterator $ iterator ) : Iterator { if ( [ ] === $ this -> order_by ) { return $ iterator ; } $ compare = function ( array $ record_a , array $ record_b ) : int { foreach ( $ this -> order_by as $ callable ) { if ( 0 !== ( $ cmp = $ callable ( $ record_a , $ record_b ) ) ) { return $ cmp ; } } return $ cmp ?? 0 ; } ; $ iterator = new ArrayIterator ( iterator_to_array ( $ iterator ) ) ; $ iterator -> uasort ( $ compare ) ; return $ iterator ; }
Sort the Iterator.
Sort the Iterator .