(customList,n,i)
| 147 | # HEAP SORT ALGORITHM |
| 148 | |
| 149 | def heapify(customList,n,i): |
| 150 | smallest = i |
| 151 | l = 2*i + 1 |
| 152 | r = 2*i + 2 |
| 153 | |
| 154 | if l < n and customList[l] < customList[smallest]: |
| 155 | smallest = l |
| 156 | if r < n and customList[r] < customList[smallest]: |
| 157 | smallest=r |
| 158 | if smallest != i: |
| 159 | customList[i], customList[smallest] = customList[smallest], customList[i] |
| 160 | heapify(customList ,n ,smallest) |
| 161 | |
| 162 | def heapSort(customList): |
| 163 | n = len(customList) |