(arr, left, right)
| 13 | # This function sorts array from left index to |
| 14 | # to right index which is of size atmost RUN |
| 15 | def insertionSort(arr, left, right): |
| 16 | for i in range(left + 1, right + 1): |
| 17 | temp = arr[i] |
| 18 | j = i - 1 |
| 19 | while j >= left and arr[j] > temp: |
| 20 | arr[j + 1] = arr[j] |
| 21 | j -= 1 |
| 22 | |
| 23 | arr[j + 1] = temp |
| 24 | |
| 25 | |
| 26 | # merge function merges the sorted runs |