|
sorting array in predefined order - uksort: msg#03633php.general
I am trying to sort array by key to a defined order - I thought uksort would be best option. Here's what i have come up with from the manual example - however it doesn't work at all. I want to sort this array by $region Array looks like this: $articles[$region][$article_id][$column_name] // END ADD ARTICLES TO MULTIDIMENSIONAL ARRAY // SORT ARRAY BY REGION function cmp ($a, $b) { if ($a == 'national') return 0; elseif ($a == 'international') return 5; elseif ($a == 'west') return 1; elseif ($a == 'south') return 2; elseif ($a == 'east') return 3; elseif ($a == 'midwest') return 4; } uksort ($articles, "cmp"); Thanks much, olinux __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Opening large text files on Windows, Analysis & Solutions |
|---|---|
| Next by Date: | Multiple LEFT JOIN SQL syntax in msaccess, Emile Bosch |
| Previous by Thread: | PATH_INFO in CGI Mode, Mauricio Cuenca |
| Next by Thread: | Multiple LEFT JOIN SQL syntax in msaccess, Emile Bosch |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |