sorting array by keys?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello;

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
lab_0
lab_1
lab_10
... etc... up to lab_13
then
lab_2
lab_3
... 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
sorting.

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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux