http://us2.php.net/manual/en/function.readdir.php states
Returns the name of the next entry in the directory. The entries are returned in the order in which they are stored by the filesystem.
So you could read the information into an array first and sort (http://us2.php.net/manual/en/function.sort.php) that or you could use other functions, e.g.
http://us2.php.net/manual/en/function.glob.php
which perform sorting.
See the other File functions for accessing other information you may want to sort by:
http://us2.php.net/manual/en/ref.filesystem.php
like
http://us2.php.net/manual/en/function.stat.php
You could adopt the answers from here:
to include the information from stat().