swap child and parent until parent is smaller
while arr [ j ] > arr [ int ( ( j - 1 ) / 2 ) ] : NEW_LINE INDENT ( arr [ j ] , arr [ int ( ( j - 1 ) / 2 ) ] ) = ( arr [ int ( ( j - 1 ) / 2 ) ] , arr [ j ] ) NEW_LINE j = int ( ( j - 1 ) / 2 ) NEW_LINE DEDENT def heapSort ( arr , n ) : NEW_LINE buildMaxHeap ( arr , n ) NEW_LINE for i in range ( n - 1 , 0 , - 1 ) : NEW_LINE