note 105811 rejected from function.array-multisort by danbrown
| From: | danbrown@php.net | Date: | Fri, 16 Sep 2011 18:58:15 +0000 |
| Subject: | note 105811 rejected from function.array-multisort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183224@lists.php.net to get a copy of this message | ||
Note Submitter: brad dot kmd at gmail dot com
----
This is my first post on this great site so please forgive me if I've done something stupid!
I'm wondering how I might sort the following so that the results come back as displayed at the
end of this comment:
<?php
$myArray[0]["word"] = "cows";
$myArray[0]["seres"] = 635000;
$myArray[1]["word"] = "cows";
$myArray[1]["seres"] = 352000;
$myArray[2]["word"] = "cats";
$myArray[2]["seres"] = 2670000;
$myArray[3]["word"] = "dogs";
$myArray[3]["seres"] = 2580000;
$myArray[4]["word"] = "dogs";
$myArray[4]["seres"] = 6270000;
$myArray[5]["word"] = "dogs";
$myArray[5]["seres"] = 851000;
$myArray[6]["word"] = "cows";
$myArray[6]["seres"] = 726000;
$myArray[7]["word"] = "cats";
$myArray[7]["seres"] = 555000;
$myArray[8]["word"] = "cats";
$myArray[8]["seres"] = 3250000;
?>
How do I sort the above (preferably without using mysql) so that it gives me the following? Note
that the following desired output is *not* in alphabetical order but is ordered in
"groups" by the "word" values by the "seres" values:
cats 6,270,000
cats 2,580,000
cats 851,000
dogs 3,250,000
dogs 2,670,000
dogs 555,000
cows 726,000
cows 635,000
cows 352,000