note 105811 added to function.array-multisort

From: Date: Fri, 16 Sep 2011 18:54:26 +0000
Subject: note 105811 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-183223@lists.php.net to get a copy of this message
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 ---- Server IP: 69.147.83.197 Probable Submitter: 74.62.79.210 ---- Manual Page -- http://www.php.net/manual/en/function.array-multisort.php Edit -- https://master.php.net/note/edit/105811 Del: integrated -- https://master.php.net/note/delete/105811/integrated Del: useless -- https://master.php.net/note/delete/105811/useless Del: bad code -- https://master.php.net/note/delete/105811/bad+code Del: spam -- https://master.php.net/note/delete/105811/spam Del: non-english -- https://master.php.net/note/delete/105811/non-english Del: in docs -- https://master.php.net/note/delete/105811/in+docs Del: other reasons-- https://master.php.net/note/delete/105811 Reject -- https://master.php.net/note/reject/105811 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183223) next »