human
Sorting all array elements except one | Python3 program to sort all elements except element at index k ..
Move k - th element to end.
Sort all elements except last.
Store last element ( originally k - th ).
Move all elements from k - th to one position ahead ..
Restore k - th element.
Driver code"
Solution in Python:
assistant
#Here is code to sorting all array elements except one and the other steps required.
 def sortExcept ( arr , k , n ) :
	arr [ k ] , arr [ - 1 ] = arr [ - 1 ] , arr [ k ]
	arr = sorted ( arr , key = lambda i : ( i is arr [ - 1 ] , i ) )
	last = arr [ - 1 ]
	i = n - 1
	while i > k :
		arr [ i ] = arr [ i - 1 ]
		i -= 1
	arr [ k ] = last
	return arr
if __name__ == ' _ _ main _ _ ' :
	a = [ 10 , 4 , 11 , 7 , 6 , 20 ]
	k = 2
	n = len ( a )
	a = sortExcept ( a , k , n )
	print ( " ▁ " . join ( list ( map ( str , a ) ) ) )