fork download
  1. def wstawianie(t, x):
  2. if x <= t[0]:
  3. t.insert(0, x)
  4. return t
  5. if x >= t[len(t) - 1]:
  6. t.insert(len(t),x)
  7. return t
  8. for i in range(len(t) - 1):
  9. if x >= t[i] and x <= t[i + 1]:
  10. t.insert(i + 1, x)
  11. return t
  12.  
  13. def sort_w(t):
  14. pom = [t[0]]
  15. for i in range(1, len(t)):
  16. wstawianie(pom, t[i])
  17. return pom
  18.  
  19. print(sort_w([23, 12, 10, 1, 2, 9]))
Success #stdin #stdout 0.04s 63436KB
stdin
Standard input is empty
stdout
[1, 2, 9, 10, 12, 23]