fork download
  1. from random import randrange
  2.  
  3. def qsort(list):
  4. if list == []:
  5. return []
  6. else:
  7. pivot = list[0]
  8. lesser = qsort([x for x in list[1:] if x < pivot])
  9. greater = qsort([x for x in list[1:] if x >= pivot])
  10. return lesser + [pivot] + greater
  11.  
  12. def qsortline(list):
  13. return [] if list==[] else qsortline([x for x in list[1:] if x < list[0]]) + [list[0]] + qsortline([x for x in list[1:] if x >= list[0]])
  14.  
  15.  
  16.  
  17. def qsortrand(list):
  18. if list == []:
  19. return []
  20. else:
  21. pivot = list.pop(randrange(len(list)))
  22. lesser = qsortrand([l for l in list if l < pivot])
  23. greater = qsortrand([l for l in list if l >= pivot])
  24. return lesser + [pivot] + greater
Success #stdin #stdout 0.03s 5444KB
stdin
Standard input is empty
stdout
Standard output is empty