note 38544 deleted from function.uksort by vincent

From: Date: Fri, 26 Dec 2003 12:34:25 +0000
Subject: note 38544 deleted from function.uksort by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62501@lists.php.net to get a copy of this message
Note Submitter: Tal Eilon ---- Can someone please help me out here? I need to sort this Array by the number from big to small. This script I wrote does part of the job but I don't know how to display back the Value of the items??? Here is the script: <? $array = Array ( "[G-3010F-2AV]" => "1", "[G-2110V-8]" => "4", "[MTD-1044A-1AVDF]" => "2", "[F-201W-1AEF]" => "1", "[PANASONIC SL-SX420]" => "16", "[MZ-N510CK SONY]" => "38", "[G-2110-1V]" => "1", "[W-59]" => "1", "[G-2600-2VMER]" => "2", "[AW-80D-2A]" => "1" ); $a = array_count_values($array); //print_r($a); function cmp($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } /* ================================================= */ uksort($a, "cmp"); while (list($key, $value) = each($a)) { echo "$key: $value\n"; } ?> --Tal

« previous php.notes (#62501) next »