Answer to Question #217138 in Python for Bhargav

Question #217138
Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.
1
Expert's answer
2021-07-14T13:07:06-0400
matrix = []
line = input().split()
M = int(line[0])
N = int(line[1])
for _ in range(0, M):
    for i in input().split():
        matrix.append(int(i))
matrix.sort()
for i in range(0, M):
    for j in range(0, N):
        print(matrix[i*N:i*N+N][j],end=' ')
    print()




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS