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)


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube