fork(1) download
  1. def wstaw(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(t):
  14. pom = [t[0]]
  15. for i in range(1, len(t)):
  16. wstaw(pom, t[i])
  17. return pom
  18.  
  19. print(sorted([34, 8, 23,12,5]))
Success #stdin #stdout 0.09s 14208KB
stdin
Standard input is empty
stdout
[5, 8, 12, 23, 34]