public function sort()
    {
        if ($this->sortedPackages === null) {
            $this->sortedPackages = [];
            reset($this->unsortedPackages);
            while (!empty($this->unsortedPackages)) {
                $resolved = $this->sortPackage(key($this->unsortedPackages));
                if ($resolved) {
                    reset($this->unsortedPackages);
                } else {
                    next($this->unsortedPackages);
                }
            }
        }

        return $this->sortedPackages;
    }
public function sort()
    {
        if ($this->sortedPackages === null) {
            $this->sortedPackages = [];
            reset($this->unsortedPackages);
            while (!empty($this->unsortedPackages)) {
                $resolved = $this->sortPackage(key($this->unsortedPackages));
                if ($resolved) {
                    reset($this->unsortedPackages);
                } else {
                    next($this->unsortedPackages);
                }
            }
        }

        return $this->sortedPackages;
    }
public function sort ( ) { if ( $ this -> sortedPackages === null ) { $ this -> sortedPackages = [ ] ; reset ( $ this -> unsortedPackages ) ; while ( ! empty ( $ this -> unsortedPackages ) ) { $ resolved = $ this -> sortPackage ( key ( $ this -> unsortedPackages ) ) ; if ( $ resolved ) { reset ( $ this -> unsortedPackages ) ; } else { next ( $ this -> unsortedPackages ) ; } } } return $ this -> sortedPackages ; }
Sorts the packages and returns the sorted packages array

@return array
Sorts the packages and returns the sorted packages array