fork download
  1. import sys
  2.  
  3. def it(i, n):
  4. yield None
  5. if (i > 0):
  6. for j in it(i-1, n):
  7. yield j
  8. else:
  9. yield n
  10.  
  11.  
  12. def Sort(its):
  13. done = False
  14. while not done:
  15. done = True
  16. for i in its:
  17. try:
  18. val = i.next()
  19. if val == None:
  20. done = False
  21. else:
  22. yield val
  23. except:
  24. its.remove(i)
  25.  
  26. iters = []
  27. for num in [1, 3, 894, 43, 12, 77, 666]:
  28. iters.append(it(num, num))
  29.  
  30. for i in Sort(iters):
  31. print i
Success #stdin #stdout 0.12s 9408KB
stdin
Standard input is empty
stdout
1
3
12
43
77
666
894