The easiest way is probably to just use a for loop.

For instance (no pun intended...well, maybe just a little one):

$imax = sizeof($joke);

for ($i = 0; $i < $imax; $i++)
{
    if (sizeof($joke[$i]) > 1)
    {
        sort($joke[$i]);
    }
}


That will handle the sorting of any two-dimensional array. It won't effect
the first dimension however, so if you want to sort that you will need to do
it first.


--
Plutarck
Should be working on something...
...but forgot what it was.



<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a question about sorting multidimensional arrays. Here is my
problem:
>
> I have an 2-d array:
> $joke[1][rating]=10;
> $joke[2][rating]=20;
> $joke[3][rating]=15;
> ....
>
> I would like to sort the jokes into an array based on the rating from
highest
> to lowest. The end result would be something like this:
> Joke 2 : 20 points
> Joke 3: 15 points
> Joke 1: 10 points
>
> How do I accomplish this?
>
> I have tried fooling around with sort(), arsort(), and array_multisort(),
but
> I just can't get it. Thank you very much for your time.
>
> Shane
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to