human
Give me a code to sort the matrix column and the other steps required given the following:
Sort the matrix column | Function to find the transpose of the matrix mat [ ].
Stores the transpose of matrix mat [ ] [ ].
Traverse each row of the matrix.
Traverse each column of the matrix.
Transpose matrix elements.
Function to sort the given matrix in row wise manner.
Traverse the row.
Row - Wise Sorting.
Function to print the matrix in column wise sorted manner.
Function call to find transpose of the the matrix mat [ ] [ ].
Sorting the matrix row - wise.
Calculate transpose of B [ ] [ ].
Print the matrix mat [ ] [ ].
Driver Code.
Input.
Function call to print the matrix in column wise sorted manner"
Solution in Python:
assistant
#Here is code to sort the matrix column and the other steps required.
 def transpose ( mat , row , col ) :
	tr = [ [ 0 for i in range ( row ) ] for i in range ( col ) ]
	for i in range ( row ) :
		for j in range ( col ) :
			tr [ j ] [ i ] = mat [ i ] [ j ]
	return tr
def RowWiseSort ( B ) :
	for i in range ( len ( B ) ) :
		B [ i ] = sorted ( B [ i ] )
	return B
def sortCol ( mat , N , M ) :
	B = transpose ( mat , N , M )
	B = RowWiseSort ( B )
	mat = transpose ( B , M , N )
	for i in range ( N ) :
		for j in range ( M ) :
			print ( mat [ i ] [ j ] , end = " ▁ " )
		print ( )
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 1 , 6 , 10 ] , [ 8 , 5 , 9 ] , [ 9 , 4 , 15 ] , [ 7 , 3 , 60 ] ]
	N = len ( mat )
	M = len ( mat [ 0 ] )
	sortCol ( mat , N , M )