Skip to content

Instantly share code, notes, and snippets.

@wlight
wlight / quickSort.php
Created March 5, 2019 08:35
快速排序
<?php
function quickSort($array) {
if(count($array) <= 1){
return $array;
}
$mid = $array[0];
$right_array = array();
$left_array = array();
for($i = 1;$i < count($array); $i++) {
if($array[$i] > $mid) {
@wlight
wlight / bubbleSort.php
Last active March 5, 2019 03:55
冒泡排序
<?php
function bubble_sort($array){
$count = count($array);
if ($count <= 0) return false;
for($i=0; $i<$count; $i++){
for($j=$i+1; $j<$count; $j++){
if ($array[$i] > $array[$j]){
$tmp = $array[$i];
$array[$i] = $array[$j];
$array[$j] = $tmp;