Re: uksort wisdom

From: Date: Tue, 05 Feb 2002 08:06:06 +0000
Subject: Re: uksort wisdom
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83553@lists.php.net to get a copy of this message
shouldn't it be: uksort($array_array,"cmp"); Greets, Edward ----- Original Message ----- From: "Sondra Russell" <sondra@sondra.com> To: <php-general@lists.php.net> Sent: Tuesday, February 05, 2002 5:52 AM Subject: [PHP] uksort wisdom > 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 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#83553) next »