<?php
use Symfony\Component\Finder\Iterator\SortableIterator;
$path = __DIR__ . '/resources';
$files = new FilesystemIterator($path);
$iterator = new SortableIterator($files, SortableIterator::SORT_BY_MODIFIED_TIME);
foreach ($iterator as $file) {
echo $file->getFilename() . ' ' .
$file->getMTime() . PHP_EOL;
}
echo str_repeat(PHP_EOL, 2);
$iterator = new SortableIterator($files, SortableIterator::SORT_BY_NAME);
foreach ($iterator as $file) {
echo $file->getFilename() . PHP_EOL;
}