(alist)
| 11 | print(insertionSort(alist)) |
| 12 | |
| 13 | def insertionSort2(alist): |
| 14 | for index in range(1, len(alist)): |
| 15 | currentvalue = alist[index] |
| 16 | position = index |
| 17 | |
| 18 | while position > 0 and alist[position-1] > currentvalue: |
| 19 | alist[position] = alist[position-1] |
| 20 | position -= 1 |
| 21 | alist[position] = currentvalue |
| 22 | |
| 23 | return alist |
| 24 | |
| 25 | print(insertionSort2(alist)) |