diff --git a/Python/sorting/quick sort.py b/Python/sorting/quick sort.py new file mode 100644 index 00000000..9e5e1ec1 --- /dev/null +++ b/Python/sorting/quick sort.py @@ -0,0 +1,19 @@ +def quick_sort(arr): + if len(arr) <= 1: + return arr[:] + + pivot = arr[0] + + less = [] + equal = [] + greater = [] + + for x in arr: + if x < pivot: + less.append(x) + elif x == pivot: + equal.append(x) + else: + greater.append(x) + + return quick_sort(less) + equal + quick_sort(greater)