We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importmathimportosimportrandomimportreimportsysif__name__=='__main__':# Read the first line: number of rows (n) and number of columns (m)nm=input().split()n=int(nm[0])#Numberofathletesm=int(nm[1])#Numberofattributesperathletearr=[]# Read the next n lines containing athlete detailsfor_inrange(n):arr.append(list(map(int,input().rstrip().split())))# Read the sorting column (k), indexed from 0k=int(input())# Sort the array based on the k-th attribute using a lambda functionarr.sort(key=lambdax:x[k])# Print the sorted arrayforrowinarr:print(" ".join(map(str,row)))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Athlete Sort
You are viewing a single comment's thread. Return to all comments →