php中常见排序简单算法分析
function reserverInfo($arr){ if(empty($arr)) return ''; $count = count($arr); $left = 0; $right = $count -1 ; while($left < $right){ $temp = $arr[$left]; $arr[$left++] = $arr[$right]; $arr[$right--] = $temp; } return $arr; }
function bubbleSort($arr){ $count = count($arr); for($i=0;$i<$count-1;$i++){ for($j=0;$j<$count-$i-1;$j++){ if($arr[$j] > $arr[$j+1]){ $temp = $arr[$j]; $arr[$j] = $arr[$j+1]; $arr[$j+1]= $temp; } } } return $arr; }