Sorting a matrix in descending order of column sums
C#
Medium
sorting
Task «Sorting a matrix in descending order of column sums»
Given a rectangular matrix of integers. It is necessary to sort the columns of the matrix in descending order of the sum of elements in the column. If the sums are equal, preserve the original order of the columns. Output the transformed matrix. The dimensions of the matrix do not exceed 100×100, and the absolute values of the elements do not exceed 1000.
Input Format
In the first line, two integers N and M — the number of rows and columns. In the next N lines, M integers each — the elements of the matrix.
Output Format
Output N rows of M integers — the matrix after sorting the columns.
Examples
Example 1
INPUT
2 4
5 1 3 2
0 0 0 0
OUTPUT
5 3 2 1
0 0 0 0
Example 2
INPUT
10 20
OUTPUT
60
main.cs