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登录查看完整内容