$arr = [0,4,8,3,2,5,6,1,9,7];
function select_sort($data){
$sorted = [];
$total = count($data);
for($i = 0; $i<$total-1; $i++){
for($j = $total-1; $j>$i; $j--){
if ($data[$i] > $data[$j]){
$tmp = $data[$i];
$data[$i] = $data[$j];
$data[$j] = $tmp;
}
}
}
return $data;
}
网友评论