(shelf, left, right, pivot_index)
| 95 | shelf.insert(j, shelf.pop(imin)) |
| 96 | |
| 97 | def partition(shelf, left, right, pivot_index): |
| 98 | pivot = shelf[pivot_index] |
| 99 | shelf.insert(right, shelf.pop(pivot_index)) |
| 100 | store_index = left |
| 101 | for i in range(left, right): # range is non-inclusive of ending value |
| 102 | if shelf[i].size < pivot.size: |
| 103 | shelf.insert(store_index, shelf.pop(i)) |
| 104 | store_index = store_index + 1 |
| 105 | shelf.insert(store_index, shelf.pop(right)) # move pivot to correct position |
| 106 | return store_index |
| 107 | |
| 108 | def qsort(shelf, left, right): |
| 109 | if left < right: |
searching dependent graphs…