Since readdir() does not use any kind
of sort, you need to put the filenames
in an array, then sort, then include
to get the idea :
function GetDirArray($sPath)
{
//Load Directory Into Array
$handle=opendir($sPath);
while ($file = readdir($handle))
$retVal[count($retVal)] = $file;
//Clean up and sort
closedir($handle);
sort($retVal);
return $retVal;
}