note 37129 deleted from function.asort by didou
| From: | didou@php.net | Date: | Wed, 28 Jan 2004 11:32:03 +0000 |
| Subject: | note 37129 deleted from function.asort by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64309@lists.php.net to get a copy of this message | ||
Note Submitter: siggi AT junesystems
----
Much simpler (imho) way to sort an array and preserve key sorting. Not sure though whether this is
faster than the previous method for large (> 1000) arrays.
$fruits=
array('apple','banana','banana','lemon','apple');
$temp = array();
foreach($tmp AS $Key => $Value) {
$temp[$Value][] = $Key;
}
ksort($temp);
$fruits= Array();
foreach($temp AS $Value => $Keys) {
asort($Keys);
foreach($Keys AS $Val) {
$fruits[$Val] = $Value;
}
}
unset($temp);