note 86654 added to function.uksort

From: Date: Tue, 28 Oct 2008 17:08:12 +0000
Subject: note 86654 added to function.uksort
Groups: php.notes 
Request: Send a blank email to php-notes+get-145885@lists.php.net to get a copy of this message
skippy at zuavra dot net noted that calling uksort with a callback that always returns 0 doesn't leave the elements in place. In fact, it seems to reverse the ordering of the array! This doesn't seem like desirable behavior... <?php function always_tie() { return 0; } $myarray = array(3, 5, 1, 7); print_r($myarray); // 3,5,1,7 uksort($myarray, 'always_tie'); print_r($myarray); // 7,1,5,3 uksort($myarray, 'always_tie'); print_r($myarray); // 3,5,1,7 ?> ---- Server IP: 209.41.74.194 Probable Submitter: 207.250.32.200 ---- Manual Page -- http://www.php.net/manual/en/function.uksort.php Edit -- https://master.php.net/note/edit/86654 Del: integrated -- https://master.php.net/note/delete/86654/integrated Del: useless -- https://master.php.net/note/delete/86654/useless Del: bad code -- https://master.php.net/note/delete/86654/bad+code Del: spam -- https://master.php.net/note/delete/86654/spam Del: non-english -- https://master.php.net/note/delete/86654/non-english Del: in docs -- https://master.php.net/note/delete/86654/in+docs Del: other reasons-- https://master.php.net/note/delete/86654 Reject -- https://master.php.net/note/reject/86654 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145885) next »