# 冒泡排序
冒泡排序是的思路是数据两两比较,将大的或者小的交换位置。
# 动图演示
![](https://box.kancloud.cn/33a947c71ad62b254cab62e5364d2813_826x257.jpg)
# 示例代码
```php
for($i = 1; $i < $length;$i++){
for($j = 0; $j < $length - $i;$j++){
if($data[$j] > $data[$j+1]){
$tmp = $data[$j];
$data[$j] = $data[$j+1];
$data[$j+1] = $tmp;
}
}
}
```