go to bug id or search bugs for
From manual page: http://www.php.net/function.scandir
Currently, scandir() commits some "userland villainry" by enforcing alphanumerical
sorting of the directory entries it pulls. In some cases I needed a "natural"
order of the entries in a directory. In another more obvious case, scandir()
created notable CPU overhead from always sorting entries in a rather huge
directory that was frequently read in the application. I had to go back to PHP4's
opendir/readdir to solve the problem.
I'd like to suggest that scandir() gets new constants introduced to $sorting_order
in order to make the sorting optional: something like SORT_NONE, SORT_ASCENDING
Add a Patch
Add a Pull Request
This looks safe enough to implement on trunk: a Google Code Search
returns no instances of a value other than 0 or 1 being used as
the second parameter to scandir(), so I think as long as we document
this in the UPGRADING file, this should be OK.
Automatic comment from SVN on behalf of aharvey
Log: Implemented FR #53407 (make scandir()'s directory sorting optional).
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.
Implemented on trunk, although I've prefixed the constants with
SCANDIR_ to match our usual constant naming a bit better, hence
SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING and SCANDIR_SORT_NONE.