Input Format
The first line contains  and  separated by a space.
The next  lines each contain  elements.
The last line contains .

Each element 
Output Format
Print the  lines of the sorted table. Each line should contain the space separated elements. Check the sample below for clarity.
hackerrank athlete sort problem solution in python

Problem solution in python 2 programming language.

n,m = map(int,raw_input().split())
lst = []
for i in range(n):
k = int(raw_input())    
print "\n".join(map(lambda x: " ".join(map(str, x)), sorted(lst, key = lambda x: x[k])))

Problem solution in python 3 programming language.

N, M = map(int, input().split())
rows = [input() for _ in range(N)]
K = int(input())

for row in sorted(rows, key=lambda row: int(row.split()[K])):