def qsort(li, reverse=False):
if len(li) == 0: return []
x, *xs = li
ys = [a for a in xs if a <= x]
zs = [b for b in xs if b > x]
if reverse:
return [*qsort(zs, reverse), x, *qsort(ys, reverse)]
return [*qsort(ys, reverse), x, *qsort(zs, reverse)]
li = [8,3,7,4,6,1,9,5,2,3,0]
print(li)
print(qsort(li))
print(qsort(li, True))
To embed this project on your website, copy the following code and paste it into your website's HTML: