Quick Sort
Here is my quick sort solution:
def quickSort(arr):
if len(arr) == 0:
return [];
less = []
greater = []
pivot = arr.pop(int(len(arr)/2))
for n in arr[:]:
if n < pivot :
less.append(n)
elif n > pivot:
greater.append(n)
return quickSort(less) + [pivot] + quickSort(greater)
print (quickSort([1,3,-4,2,99,10,101,100,45,67,-34,234]))
Written by Agam
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#