Web lists-archives.com

[PHP] sorting array by keys?


I have been consulting the manual and playing with a few different approaches to this;

this comes the closest to what I want:

function sortAlg($_a, $_b)
                   return strcasecmp($_a, $_b);
         uksort($_result['dirs'], 'sortAlg');

$_result['dirs'] is itself an array where the associative string keys are what I want to sort by.

Everything works fine, accept
I have a series of directories that follow the naming pattern 'lab_#'
so, what happens with the sort is that the labs come out
... etc... up to lab_13
... etc... up to lab_9

Am I going to have to code to find these cases and sort them as a separate array by keys?

This is also coming out of Apache on a FreeBSD system. The sorting order appears to be creation date, as the last items created in this part of the file system appear last without any

Without any sorting most of the lab_# names come out in the right order, but that is, I believe, because all of these directories and files were posted via ftp transfer at the same time.

So, lab_0 through lab_8 come out in the right order, but lab_9 through lab_13 seem to
appear according to subsequent creation date.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php