选择排序的php实现
<?php
function selection_sort(array $anArr
){        
    for(
$i 0;$i count($anArr); $i
++){        
        
$s $i
;        
        for(
$j $i 1;$j count($anArr);$j 
++){                        
            if(
$anArr[$j] < $anArr[$s
]){        
                
$s $j
;        
            }                        
        }        
        
swap($anArr[$i], $anArr[$s
]);        
    }        
    return 
$anArr
;        

?>
posted on 2010-03-21 08:31  fancing  阅读(108)  评论(0编辑  收藏  举报