Re: Sorting an array of arrays....
| From: | Toni Kustiana | Date: | Fri, 15 Feb 2002 01:37:46 +0000 |
| Subject: | Re: Sorting an array of arrays.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84852@lists.php.net to get a copy of this message | ||
try to add to your script:
function cmp ($a, $b) {
return strcmp($a["3"],$b["3"]);
}
usort($data, "cmp");
"Fifield, Mike" <Mike.Fifield@schwab.com> wrote: 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
---------------------------------
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!