note 102701 deleted from function.usort by danbrown
[email protected] Tue, 1 Mar 2011 06:17:07 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
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);
?>