note 96602 deleted from function.usort by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:24:06 +0000 |
| Subject: | note 96602 deleted from function.usort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176059@lists.php.net to get a copy of this message | ||
Note Submitter: nicolas dot demarque at gmail dot com
----
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;
}
}
?>