fork download
  1. # your code goes here
  2. def qsort(L):
  3. if len(L) < 1 : return L
  4. print(L)
  5. L_plus = []
  6. L_minus = []
  7. pivot = len(L) // 2
  8. for e in L :
  9. if e > L[pivot]:
  10. L_plus += [e]
  11. if e < L[pivot]:
  12. L_minus += [e]
  13. else:
  14. continue
  15. return qsort(L_minus)+ [L[pivot]] +qsort(L_plus)
  16.  
  17. L = [8, 5, 3, 7, 9, 2, 6]
  18. print(qsort(L))
Success #stdin #stdout 0.04s 9344KB
stdin
Standard input is empty
stdout
[8, 5, 3, 7, 9, 2, 6]
[5, 3, 2, 6]
[5, 3, 6]
[5, 6]
[5]
[8, 9]
[8]
[2, 3, 5, 6, 7, 8, 9]