Row wise sorting in 2D array | Python3 code to sort 2D matrix row - wise ; One by one sort individual rows . ; printing the sorted matrix ; Driver code
def sortRowWise ( m ) : NEW_LINE INDENT for i in range ( len ( m ) ) : NEW_LINE INDENT m [ i ] . sort ( ) NEW_LINE DEDENT for i in range ( len ( m ) ) : NEW_LINE INDENT for j in range ( len ( m [ i ] ) ) : NEW_LINE INDENT print ( m [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT m = [ [ 9 , 8 , 7 , 1 ] , [ 7 , 3 , 0 , 2 ] , [ 9 , 5 , 3 , 2 ] , [ 6 , 3 , 1 , 2 ] ] NEW_LINE sortRowWise ( m ) NEW_LINE