Your comparison function doesn't compare anything.

You should look at $a and $b and return an answer indicating which one 
comes first. If you want $a to come before $b, return -1. If they're the 
same, return 0. If you want $a to come after $b in the sorted list, return 
1.

miguel

On Fri, 24 May 2002, olinux wrote:
> 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

Reply via email to