SortIterator (class)
Class SortIterator
An iterator that will return the passed items in order. The order is given by the value returned in a callback function that maps each of the elements.
Example:
$items = [$user1, $user2, $user3]; $sorted = new SortIterator($items, function ($user) { return $user->age; }); // output all user name order by their age in descending order foreach ($sorted as $user) { echo $user->name; }
This iterator does not preserve the keys passed in the original elements.
- IteratorIterator implements Iterator, Traversable, OuterIterator
- Cake\Collection\Collection im