Implemented the quick sort algorithm in python, It was just for learning it, now I want to port it to C.
Thoughts on the quality of my python implementation?
from random import randint, shuffle
def swap(array, a, b):
array[a], array[b] = array[b], array[a]
def quick_sort(array, start=0, end=None):
if end is None:
end = len(array) - 1
if end - start >= 1:
pivot = array[end]
a = start
b = end - 1
while not a > b:
if not array[a] > pivot:
a += 1
continue
else:
if array[b] < pivot:
swap(array, a, b)
a += 1
b -= 1
swap(array, a, end)
quick_sort(array, start, a - 1)
quick_sort(array, a + 1, end)
arr = [randint(0, 30) for _ in range(20)]
print(arr)
quick_sort(arr)
print(arr)