Create quicksort
that appears in Learn You Haskell for Great Good in python with list comprehension and recursion as it is. That's it, but I'll leave it for the time being as it may be useful for something someday.
def quicksort(x):
if x==[]: return []
smallerSorted = quicksort([a for a in x[1:] if a <= x[0]])
biggerSorted = quicksort([a for a in x[1:] if a > x[0]])
return(smallerSorted+[x[0]]+biggerSorted)
x = [10,2,5,3,1,6,7,4,2,3,4,8,9]
print(quicksort(x))
[1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10]
Recommended Posts