Computer Science - Algorithms - Insertion sort - Insertion Sort Algorithm
4 steps. Step 1 'How It Works': Start with first element as 'sorted' portion. Take next element (key). Shift sorted elements right until correct position found. Insert key. Repeat for all elements. Step 2 'Code': def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i]; j = i-1; while j >=