In this HackerRank Evaluation problem solution, You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight, and so on). You are required to sort the data based on the Kth attribute and print the final resulting table.

HackerRank Athlete Sort in python problem solution

HackerRank Athlete Sort in python problem solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
from fileinput import *

m_n = raw_input()
mn = m_n.split()
m = mn[0]
n = mn[1]
arr = []
for i in range(int(m)):
    temp = raw_input()
    arr.append(temp.split())

k = raw_input()
arr2 = [[int(j) for j in i] for i in arr]
#print arr2
new = sorted(arr2,key = lambda arr2:arr2[int(k)])

print('\n'.join([' '.join([str(item) for item in row]) 
      for row in new]))