A-A+
PHP冒泡排序代码实现
<pre>function bsort(array $array){ $count = count($array); if($count == 0){ return array(); }elseif($count == 1){ return $array; }elseif($count > 1){ for($i=0;$i<$count;$i++){ for($j=$count-1;$j>$i;$j--){ if($array[$j]<$array[$j-1]){ $temp = $array[$j]; $array[$j] = $array[$j-1]; $array[$j-1] = $temp; } } } return $array; }else{ return false; } } $arr = array(56,2,5,12,78,110,36,52,77,89,3,10); print_r(bsort($arr));</pre>