SHARE
TWEET

Untitled

a guest Nov 13th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def insertionSort(arr):
  2.     for index in range(1, len(arr)):
  3.         j = index
  4.         while j > 0 and arr[j-1] > arr[j]:
  5.             arr[j], arr[j-1] = arr[j-1], arr[j]
  6.             j -= 1
  7.     return arr
  8.  
  9. print(insertionSort([5, 4, 3, 2, 1]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top