Last Updated: February 25, 2016
·
476
· agam360

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]))