human
Sort 1 to N by swapping adjacent elements | Return true if array can be sorted otherwise false.
Check bool array B and sorts elements for continuous sequence of 1.
Sort array A from i to j.
Check if array is sorted or not.
Driver program to test sortedAfterSwap ( )"
Solution in Python:

Give me a code to sort 1 to N by swapping adjacent elements and the other steps required?
assistant
#Here is code to sort 1 to N by swapping adjacent elements and the other steps required.
 def sortedAfterSwap ( A , B , n ) :
	for i in range ( 0 , n - 1 ) :
		if ( B [ i ] == 1 ) :
			j = i
			while ( B [ j ] == 1 ) :
				j = j + 1
			A = A [ 0 : i ] + sorted ( A [ i : j + 1 ] ) + A [ j + 1 : ]
			i = j
	for i in range ( 0 , n ) :
		if ( A [ i ] != i + 1 ) :
			return False
	return True
A = [ 1 , 2 , 5 , 3 , 4 , 6 ]
B = [ 0 , 1 , 1 , 1 , 0 ]
n = len ( A )
if ( sortedAfterSwap ( A , B , n ) ) :
	print ( " A ▁ can ▁ be ▁ sorted " )
else :
	print ( " A ▁ can ▁ not ▁ be ▁ sorted " )