12 namespace Symfony\Component\Finder\Iterator;
42 if (self::SORT_BY_NAME ===
$sort) {
43 $this->sort =
function ($a, $b) {
44 return strcmp($a->getRealpath(), $b->getRealpath());
47 $this->sort =
function ($a, $b) {
48 if ($a->isDir() && $b->isFile()) {
50 }
elseif ($a->isFile() && $b->isDir()) {
54 return strcmp($a->getRealpath(), $b->getRealpath());
57 $this->sort =
function ($a, $b) {
58 return ($a->getATime() - $b->getATime());
61 $this->sort =
function ($a, $b) {
62 return ($a->getCTime() - $b->getCTime());
65 $this->sort =
function ($a, $b) {
66 return ($a->getMTime() - $b->getMTime());
71 throw new \InvalidArgumentException(
'The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
77 $array = iterator_to_array($this->iterator,
true);
78 uasort($array, $this->sort);
80 return new \ArrayIterator($array);