Once the array is sorted Re - fill the array again in the mentioned way in the approach
low = 0 NEW_LINE high = n - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( i % 2 == 0 ) : NEW_LINE INDENT b [ low ] = a [ i ] NEW_LINE low += 1 NEW_LINE DEDENT else : NEW_LINE INDENT b [ high ] = a [ i ] NEW_LINE high -= 1 NEW_LINE DEDENT DEDENT