- 1
- 2
- 3
- 4
from random import randint
def qsort(l, rnd=0):
return (qsort([x for x in l if x < l[rnd]], rnd=randint(0, len([x for x in l if x < l[rnd]]) - 1) if [x for x in l if x < l[rnd]] else -1) + [x for x in l if x == l[rnd]] + qsort([x for x in l if x > l[rnd]], rnd=randint(0, len([x for x in l if x > l[rnd]]) - 1) if [x for x in l if x > l[rnd]] else -1)) if len(l) > 1 else l