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