LearnPy Hub
← NumPy problems
Medium

Sort Rows by a Column

Read r rows of integers (same length) and a column index k. Print the rows sorted by column k from smallest to largest, using argsort. Rows with equal values keep their order (use kind='stable').

Input

r, the rows, then k.

Output

r lines.

Sample 1

Input
3
3 1
1 2
2 0
0
Output
1 2
2 0
3 1

Sample 2

Input
1
5 6 7
2
Output
5 6 7
solution.py
Output appears here
Sort Rows by a Column · Python practice problem · LearnPy Hub