sol4r

Insertion Sort

Jun 17th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. l = list(map(int, input().split(' ')))
  2. for i in range(1, len(l)):
  3.     val = l[i]
  4.     j = i - 1
  5.     while j >= 0 and val < l[j]:
  6.         l[j + 1] = l[j]
  7.         j -= 1
  8.     l[j + 1] = val
  9. print(l)
Add Comment
Please, Sign In to add comment