Re: Sort Array

From: Date: Tue, 18 Jul 2006 14:34:45 +0000
Subject: Re: Sort Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-239550@lists.php.net to get a copy of this message
At 10:51 AM 7/18/2006, weetat wrote:
Hi I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"), "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"), "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"), )
You do not way how the array is created. If from a database, add " SORT by Model, Country " to your query and let the database do the work. Otherwise, read up on ar_multisort(), but I do not think you are going to find a built-in way of sorting one array on two indexes or key values. Regards - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006

« previous php.general (#239550) next »