note 102701 deleted from function.usort by danbrown
| From: | danbrown@php.net | Date: | Tue, 01 Mar 2011 14:17:07 +0000 |
| Subject: | note 102701 deleted from function.usort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177437@lists.php.net to get a copy of this message | ||
Note Submitter: Cuong Huy To
----
Probably a bug or an undocumented feature: usort() sorts your list even if you don't want to.
Detail:
If you call usort($your_list, "your_call_back_function"), where inside the
your_call_back_function() you return 0 immediately, then you would expect $your_list to be
unchanged. But in fact it is changed.
Code:
<?php
function your_call_back_function($left, $right){
return 0;
}
$your_list = array(1, 3, 2);
usort($your_list, "your_call_back_function");
print_r($your_list);
?>