Multi-Sort -- how to do this?

From: Date: Wed, 17 Jun 2009 21:11:44 +0000
Subject: Multi-Sort -- how to do this?
Groups: php.general 
Request: Send a blank email to php-general+get-294179@lists.php.net to get a copy of this message
Hi gang: Here's the problem. Let's say you have a collection of arrays, such as: $a = array(); $b = array(); $c = array(); $d = array(); And then you populate the arrays like so: while(...) { $a[] = ... $b[] = ... $c[] = ... $d[] = ... } 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] Is there a slick way to do that? Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#294179) next »