I am working on Quick sort algorithm using python . Recently I found a blog on this algorithm which was very easy to understand. I followed excatly the steps that are suggested,but still the program is not working. The idea here is take the pivot element(any random element) and sort the array left to pivot(less than pivot) and right to the pivot(greater than pivot).This is a recursive process .Here is the code.
arr = [51,1,21,11,52]
def sort_(arr):
pivot = arr[0]
left = []
right = []
for i in arr:
#print(i>=pivot)
if i >= pivot :
#print(i)
right.append(i)
elif i < pivot:
#r
left.append(i)
#return sort_(left) + [pivot] + sort_(right)
#print(left)
return sort_(left) + [pivot] + sort_(right)
sort_(arr)