I use the Finder of Symfony to search for a specific file name in directories. I need to sort the result by the directory depth. A file with depth 0 (root folder) should be on top, a file with depth 7 should be the very last.
Available sorting mechanism only sort by name and don't consider the directory deepth. E.g. "Sort by name"
$finder->sortByName(true);
a/acme/conf.yaml
conf.yaml
m/conf.yaml
o/data/a/b/c/d/conf.yaml
t/data/conf.yaml
w/data/conf.yaml
I want conf.yaml
to be on top, o/data/a/b/c/d/conf.yaml
should be at the bottom.
I found an issue in Symfony (https://github.com/symfony/symfony/issues/11289) but no suggestion for a neat sorting method.