RE: [PHP] Sorting an array of arrays....

From: Date: Thu, 14 Feb 2002 18:59:18 +0000
Subject: RE: [PHP] Sorting an array of arrays....
Groups: php.general 
Request: Send a blank email to php-general+get-84791@lists.php.net to get a copy of this message
Does anyone have an example of code that does this, I have been trying to decipher the instructions on the use of uasort but it does not make a hole lot of sense. They are using static keys and sorting by one of the array elements of each of there static keys. It does not seem like one should have to do it this way. I need it to go through each key and sort the keys based on a value in the array held in that key. Thanks Mike -----Original Message----- From: Darren Gamble [mailto:Darren.Gamble@sjrb.ca] Sent: Thursday, February 14, 2002 9:35 AM To: 'Fifield, Mike'; php-general@lists.php.net Subject: RE: [PHP] Sorting an array of arrays.... Good day, uasort() should do what you need. http://www.php.net/manual/en/function.uasort.php There's an example for the usort function that does something similar to what you want, in fact. ============================ Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 -----Original Message----- From: Fifield, Mike [mailto:Mike.Fifield@schwab.com] Sent: Thursday, February 14, 2002 9:26 AM To: php-general@lists.php.net Subject: [PHP] Sorting an array of arrays.... What I am trying to do is sort a array of arrays but I want to sort by one of the pieces of data stored in the arrays inside the array. For example; $data[blue] = array("name", "age", "time", "3"); $data[green] = array("name", "age", "time", "7"); $data[red] = array("name", "age", "time", "6"); $data[yellow] = array("name", "age", "time", "2"); $data[white] = array("name", "age", "time", "1"); $data[black] = array("name", "age", "time", "9"); I want to be able to sort this array of arrays by the very last element, the numbers. Mike Fifield Charles Schwab & Co, Inc. WARNING: All e-mail sent to or from this address will be received by the Charles Schwab corporate e-mail system and is subject to archival and review by someone other than the recipient. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#84791) next »