human
Write me a code to row wise sorting in 2D array and the other steps required given the following:
Row wise sorting in 2D array | Python3 code to sort 2D matrix row - wise.
loop for rows of matrix.
loop for column of matrix.
loop for comparison and swapping.
swapping of elements.
printing the sorted matrix.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to row wise sorting in 2D array and the other steps required.
 def sortRowWise ( m ) :
	for i in range ( len ( m ) ) :
		for j in range ( len ( m [ i ] ) ) :
			for k in range ( len ( m [ i ] ) - j - 1 ) :
				if ( m [ i ] [ k ] > m [ i ] [ k + 1 ] ) :
					t = m [ i ] [ k ]
					m [ i ] [ k ] = m [ i ] [ k + 1 ]
					m [ i ] [ k + 1 ] = t
	for i in range ( len ( m ) ) :
		for j in range ( len ( m [ i ] ) ) :
			print ( m [ i ] [ j ] , end = " ▁ " )
		print ( )
m = [ [ 9 , 8 , 7 , 1 ] , [ 7 , 3 , 0 , 2 ] , [ 9 , 5 , 3 , 2 ] , [ 6 , 3 , 1 , 2 ] ]
sortRowWise ( m )