diff --git a/codehero/perg_match.php b/codehero/perg_match.php new file mode 100644 index 0000000..99086df --- /dev/null +++ b/codehero/perg_match.php @@ -0,0 +1 @@ + $arr[$j+1]) { $tmp = $arr[$j]; $arr[$j] = $arr[$j+1]; $arr[$j+1] = $tmp; } } } return $arr; } $sort = bubble_sort([2,6,19,4,5,8,3]); var_dump($sort); \ No newline at end of file diff --git a/suanfa/Base/quick_sort.php b/suanfa/Base/quick_sort.php new file mode 100644 index 0000000..2128d1e --- /dev/null +++ b/suanfa/Base/quick_sort.php @@ -0,0 +1 @@ += $base) { $right[] = $value; } else { $left[] = $value; } } if (count($left)) $left = quick_sort($left); if (count($right)) $right = quick_sort($right); return array_merge($left, [$base], $right); } $sort = quick_sort([2,6,19,4,5,8,3]); var_dump($sort); \ No newline at end of file