Re: Sorting multi-dimensional arrays, and the crashes are still happening.
| From: | Andrei Zmievski | Date: | Tue, 11 Jul 2000 16:53:36 +0000 |
| Subject: | Re: Sorting multi-dimensional arrays, and the crashes are still happening. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5946@lists.php.net to get a copy of this message | ||
> > Also, how do you sort multi-dimensional arrays?
> >
> > I have an array ($myArray[][]) that contains data like:
> >
> > 23 Steve steve@sdkjs.com
> > 12 Jon jon@smskdjc.com
> > 29 Anna anna.ks@jlasdlkajsd.co.uk
> > 73 Jon jon@jskajkasljisdouebnmass.com
> >
> > How do I sort by the number (biggest first)?
>
> Well, if you can wait just a big, I've just committed a function called
> array_multisort() that will do exactly what you want and much more. :)
> Stay tuned for documentation as well.
Of course, I meant to say "just a bit". And here is how you would use
array_multisort() to do what you want:
array_multisort($myArray[0], SORT_NUMERIC, SORT_DESC, $myArray[1], $myArray[2]);
-Andrei
* The best source is the source code. *