note 100325 added to function.uasort

From: Date: Fri, 08 Oct 2010 07:20:34 +0000
Subject: note 100325 added to function.uasort
Groups: php.notes 
Request: Send a blank email to php-notes+get-173077@lists.php.net to get a copy of this message
Took me some time to figure that out: the user function must return an *integer*, if you return a float, you may not get the expected result. <?php $a = ('a' => 0.9, 'b' => 0.7, 'c' => 0.8); function sorting($a, $b) { return $a - $b; } // The function above will not =work, you have to function sorting($a, $b) { $d = $a = $b; return $d < 0 ? -1 : ($d > 0 ? 1 : 0); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 110.5.47.62 ---- Manual Page -- http://www.php.net/manual/en/function.uasort.php Edit -- https://master.php.net/note/edit/100325 Del: integrated -- https://master.php.net/note/delete/100325/integrated Del: useless -- https://master.php.net/note/delete/100325/useless Del: bad code -- https://master.php.net/note/delete/100325/bad+code Del: spam -- https://master.php.net/note/delete/100325/spam Del: non-english -- https://master.php.net/note/delete/100325/non-english Del: in docs -- https://master.php.net/note/delete/100325/in+docs Del: other reasons-- https://master.php.net/note/delete/100325 Reject -- https://master.php.net/note/reject/100325 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173077) next »