keky

Insertion sort

Mar 25th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. def InsertionSort(A):
  2.     for j in range(1, len(A), 1):
  3.         key = A[j]
  4.         i = j - 1
  5.         while i > -1 and A[i] > key:
  6.             A[i+1] = A[i]
  7.             i -= 1
  8.         A[i+1] = key
Advertisement
Add Comment
Please, Sign In to add comment