Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import*
- def qsort(ls):
- if len(ls)<=1:
- return ls
- pivot = choice(ls)
- left=[i for i in ls if i < pivot]
- x =[i for i in ls if i == pivot]
- right =[ i for i in ls if i >pivot]
- return qsort(left) + x + qsort(right)
- ls=[randint(0,100) for _ in range(10)]
- print(*ls)
- print(*qsort(ls))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement