src/Collection/TasksCollection.php
public function sortByPriority(GrumPHP $grumPHP): self
    {
        $priorityQueue = new SplPriorityQueue();
        $stableSortIndex = PHP_INT_MAX;
        foreach ($this->getIterator() as $task) {
            $metadata = $grumPHP->getTaskMetadata($task->getName());
            $priorityQueue->insert($task, [$metadata['priority'], $stableSortIndex--]);
        }

        return new self(array_values(iterator_to_array($priorityQueue)));
    }
public function sortByPriority(GrumPHP $grumPHP): self
    {
        $priorityQueue = new SplPriorityQueue();
        $stableSortIndex = PHP_INT_MAX;
        foreach ($this->getIterator() as $task) {
            $metadata = $grumPHP->getTaskMetadata($task->getName());
            $priorityQueue->insert($task, [$metadata['priority'], $stableSortIndex--]);
        }

        return new self(array_values(iterator_to_array($priorityQueue)));
    }
public function sortByPriority ( GrumPHP $ grumPHP ) : self { $ priorityQueue = new SplPriorityQueue ( ) ; $ stableSortIndex = PHP_INT_MAX ; foreach ( $ this -> getIterator ( ) as $ task ) { $ metadata = $ grumPHP -> getTaskMetadata ( $ task -> getName ( ) ) ; $ priorityQueue -> insert ( $ task , [ $ metadata [ 'priority' ] , $ stableSortIndex -- ] ) ; } return new self ( array_values ( iterator_to_array ( $ priorityQueue ) ) ) ; }
This method sorts the tasks by highest priority first.
This method sorts the tasks by highest priority first .