public function sortByPriority() { $iterator = $this->getIterator(); $iterator->uasort(function ($a, $b) { return $a->getPriority() < $b->getPriority() ? -1 : 1; }); $collection = new SubclassCollection(iterator_to_array($iterator)); $this->_elements = $collection->toArray(); }