(arr, left, right)
| 109 | |
| 110 | |
| 111 | def partition(arr, left, right): |
| 112 | pivot = left |
| 113 | index = pivot + 1 |
| 114 | i = index |
| 115 | while i <= right: |
| 116 | if arr[i] < arr[pivot]: |
| 117 | swap(arr, i, index) |
| 118 | index += 1 |
| 119 | i += 1 |
| 120 | swap(arr, pivot, index - 1) |
| 121 | return index - 1 |
| 122 | |
| 123 | |
| 124 | def swap(arr, i, j): |