清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
冒泡算法
<?php function bubbleSort($ary){ $len = count($ary); for ($i=0; $i < $len - 1; $i++) { for ($j=0; $j < $len - 1 -$i; $j++) { if ($ary[$j] > $ary[$j + 1]) { $tmp = $ary[$j]; $ary[$j] = $ary[$j + 1]; $ary[$j + 1] = $tmp; } } } return $ary; } $ary = [1,6,789,3,56,8,1234,45]; $newAry = bubbleSort($ary); print_r($newAry); ?>