基本思想是:每次比较两个相邻的元素,如果他们的顺序错误就把他们交换过来
~~~
$a = [12,35.2,99,18.4,76];
for($i = 0; $i < count($a)-1; $i++){
for($j = 0; $j < count($a)-1; $j++){
if($a[$j] > $a[$j+1]){
$t = $a[$j];
$a[$j] = $a[$j+1];
$a[$j+1] = $t;
}
}
}
var_dump($a);
~~~