Shifting the max . The equal condition happens if we shifted the max to arr [ min_i ] in the previous swap .
if ( arr [ min_i ] == max ) : NEW_LINE INDENT temp = arr [ j ] NEW_LINE arr [ j ] = arr [ min_i ] NEW_LINE arr [ min_i ] = temp NEW_LINE DEDENT else : NEW_LINE INDENT temp = arr [ j ] NEW_LINE arr [ j ] = arr [ max_i ] NEW_LINE arr [ max_i ] = temp NEW_LINE DEDENT i += 1 NEW_LINE j -= 1 NEW_LINE print ( " Sorted ▁ array : " , end = " ▁ " ) NEW_LINE for i in range ( n ) : NEW_LINE print ( arr [ i ] , end = " ▁ " ) NEW_LINE