(arr, start)
Min heapify helper for min_heap_sort
Min heapify helper for min_heap_sort
Min heapify helper for min_heap_sort
def min_heapify(arr, start):
    """ Min heapify helper for min_heap_sort
    """
    # Offset last_parent by the start (last_parent calculated as if start index was 0)
    # All array accesses need to be offet by start
    end = len(arr) - 1
    last_parent = int((end - start - 1) / 2)

    # Iterate from last parent to first
    for parent in range(last_parent, -1, -1):
        current_parent = parent

        # Iterate from current_parent to last_parent
        while current_parent <= last_parent:
            # Find lesser child of current_parent
            child = 2 * current_parent + 1
            if child + 1 <= end - start and arr[child + start] > arr[child + 1 + start]:
                child = child + 1

            # Swap if child is less than parent
            if arr[child + start] < arr[current_parent + start]:
                temp = arr[current_parent + start]
                arr[current_parent + start] = arr[child + start]
                arr[child + start] = temp

                current_parent = child
            # If no swap occured, no need to keep iterating
            else:
                break
def min_heapify ( arr , start ) : # Offset last_parent by the start (last_parent calculated as if start index was 0) # All array accesses need to be offet by start end = len ( arr ) - 1 last_parent = int ( ( end - start - 1 ) / 2 ) # Iterate from last parent to first for parent in range ( last_parent , - 1 , - 1 ) : current_parent = parent # Iterate from current_parent to last_parent while current_parent <= last_parent : # Find lesser child of current_parent child = 2 * current_parent + 1 if child + 1 <= end - start and arr [ child + start ] > arr [ child + 1 + start ] : child = child + 1 # Swap if child is less than parent if arr [ child + start ] < arr [ current_parent + start ] : temp = arr [ current_parent + start ] arr [ current_parent + start ] = arr [ child + start ] arr [ child + start ] = temp current_parent = child # If no swap occured, no need to keep iterating else : break