uksort wisdom

From: Date: Tue, 05 Feb 2002 04:52:21 +0000
Subject: uksort wisdom
Groups: php.general 
Request: Send a blank email to php-general+get-83467@lists.php.net to get a copy of this message
Hi Guys! I'm looking to get a *deeper understanding* of uksort. My quandry: $array[listing1][name] = "listing 1"; $array[listing1][premiere] = ""; $array[listing2][name] = "listing 2"; $array[listing2][premiere] = ""; $array[listing3][name] = "listing 3"; $array[listing3][premiere] = "yes"; I'd like the result to come out as: $array[listing3] //(this is the one with the premiere set to "yes") $array[listing1] // (no premiere, but in order) $array[listing2] // (again, no premiere, but again in order) So far, I've got: function cmp= ($a,$b) { global $array; if ($array [$a][premiere] == "yes") { return -1; } else { return ($a < $b) ? -1 : 1; } } uksort($array_array,cmp); But that ends up, strangely with: $array[listing3] $array[listing2] $array[listing1] Any wisdom? Just would like a better idea of the inner workings of uksort. Best, Sondra

« previous php.general (#83467) next »