Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insertion_sort(L):
- n = len(L)
- for i in range(1, n):
- for j in range(0, i):
- if L[j] > L[i]:
- L[i], L[j] = L[j], L[i]
- if __name__ == "__main__":
- L = [6, 1, 4, 9, 2]
- print("Before sort:", L)
- insertion_sort(L)
- print("After sort:", L)
Add Comment
Please, Sign In to add comment