Write a program that rearranges the rows of a matrix so that the values in the K
column are in descending order. Rows whose values in the K
column are equal must be output in the same order in which they were in the original matrix.
Input
The first line contains space-separated dimensions of the matrix: the number of rows N
and the number of columns M
( 1 <= N ;, M <= 100 ). The following N
lines contain matrix rows, each – by M
natural numbers separated by spaces. The last line is the column number K
.
Output
The program should output the resulting matrix, in which the rows are rearranged so that the values in the K
column are in descending order.
Examples
# |
Input |
Output |
1 |
4 5
21 22 23 24 25
26 12 18 29 33
11 37 31 14 39
16 17 18 5 20
1
|
26 12 18 29 33
21 22 23 24 25
16 17 18 5 20
11 37 31 14 39
|
Запрещенные операторы:sort