Edit report at http://bugs.php.net/bug.php?id=53407&edit=1
ID: 53407 Updated by: ahar...@php.net Reported by: stolen dot data dot net at gmail dot com Summary: make scandir()'s directory sorting optional -Status: Open +Status: Assigned Type: Feature/Change Request Package: Directory function related Operating System: applies to all (OpenBSD for me) PHP Version: 5.3.3 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2010-11-25 21:20:52] stolen dot data dot net at gmail dot com Description: ------------ --- >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 and SORT_DESCENDING. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53407&edit=1