Re: Multi-Sort -- how to do this?

From: Date: Thu, 18 Jun 2009 17:45:07 +0000
Subject: Re: Multi-Sort -- how to do this?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-294276@lists.php.net to get a copy of this message
tedd wrote:
At 10:11 AM +0100 6/18/09, Ford, Mike wrote:
On 17 June 2009 22:12, tedd advised: -snip-
Now, let's say you want to sort the $d array, but you also want the arrays $a, $b, and $c to be arranged in the same resultant order as
$d.
For example, please follow this: Before sort of $d: $a = [apple, banana, grape, orange] $b = [100, 2111, 198, 150] $c = [red, yellow, purple, orange] $d = [100, 300, 11, 50] After sort of $d: $a = [grape, orange, apple, banana] $b = [198, 150, 100, 2111] $c = [purple, orange, red, yellow] $d = [11, 50, 100, 300]
array_multisort($d, $a, $b, $c) should do what you want, Cheers! Mike
Mike: Slick indeed! That's exactly what I was looking for (see subject line -- I was close). Here's the working example: http://www.webbytedd.com/bbbb/multisort/ Thanks to Rob and Daniel for also playing, better luck next time. :-) <- note smiley -- I do appreciate your time.
Mine version retains key associations. It wasn't a complete waste of time. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#294276) next »