M=int(input("Enter the number of rows: "))
N=int(input("Enter the number of columns: "))
num= []
for i in range(0,M):
valStr=input("")
val=valStr.split()
for v in val:
num.append(int(v))
num.sort()
num2D=[]
num2D = [num[x*N:(x+1)*N] for x in range(0,M)]
print()
for row in num2D:
for element in row:
print(element, end=' ')
print()
Comments
Leave a comment