This is an implementation of quick sort which is easier for me to understand than the others I found. Although, this implementation does not appear to be "in place" as quick sort is apparently supposed to be. I'm thinking it isn't "in place" because you're returning a new array.
Am I correct in thinking that this implementation is not "in place"?
def quick_sort(sequence):
length = len(sequence)
if length <= 1:
return sequence
else:
pivot = sequence.pop()
items_greater = []
items_lower = []
for item in sequence:
if item > pivot:
items_greater.append(item)
else:
items_lower.append(item)
return quick_sort(items_lower) + [pivot] + quick_sort(items_greater)
This is another implementation I found which I think IS an "in place" version of quick sort. -> https://stackabuse.com/quicksort-in-python/
If somebody could confirm this. I would be very appreciative. Thanks!