HackerRank Python - Athlete Sort

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. Follow the example given below for better understanding.

  1. #!/bin/python3
  2. import math
  3. import os
  4. import random
  5. import re
  6. import sys
  7. N, M = map(int, input().split())
  8. rows = [input() for _ in range(N)]
  9. K = int(input())
  10. for row in sorted(rows, key=lambda row: int(row.split()[K])):
  11. print(row)

download android app