note 96602 added to function.usort
| From: | nicolas dot demarque at gmail dot com | Date: | Sun, 07 Mar 2010 19:02:29 +0000 |
| Subject: | note 96602 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166761@lists.php.net to get a copy of this message | ||
usort function has problem,if you use more than one time : sorts used before are lost.
So i have write this function which functions ;)
A problem rest, this function spend 30% more processor's time.
<?php
function usort(&$tableau, $fonction){
while(count($tableau)>0){
reset($tableau);
$pluspetit = key($tableau);
foreach($tableau as $c=>$v){
if(call_user_func($fonction, $tableau[$pluspetit], $v)>0){
$pluspetit = $c;
}
}
$result[]=$tableau[$pluspetit];
unset($tableau[$pluspetit]);
}
$tableau = $result;
}
}
?>
----
Server IP: 89.31.146.176
Probable Submitter: 188.73.36.172
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/96602
Del: integrated -- https://master.php.net/note/delete/96602/integrated
Del: useless -- https://master.php.net/note/delete/96602/useless
Del: bad code -- https://master.php.net/note/delete/96602/bad+code
Del: spam -- https://master.php.net/note/delete/96602/spam
Del: non-english -- https://master.php.net/note/delete/96602/non-english
Del: in docs -- https://master.php.net/note/delete/96602/in+docs
Del: other reasons-- https://master.php.net/note/delete/96602
Reject -- https://master.php.net/note/reject/96602
Search -- https://master.php.net/manage/user-notes.php