Create a queue with value-priorities

Code
<?php

// SplPriorityQueue is more like a heap
$queue = new SplPriorityQueue();

$queue->insert('second'2);
$queue->insert('third'1);
$queue->insert('first'3);

foreach (
$queue as $element) {
    
// returns value by default
    
echo $element PHP_EOL;
}

echo 
'count: ' count($queue);
Result
first
second
third
count: 0
Used Versions
PHP 8.0, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8