-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAthlete Sort.py
More file actions
33 lines (24 loc) · 827 Bytes
/
Athlete Sort.py
File metadata and controls
33 lines (24 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Link: https://www.hackerrank.com/challenges/python-sort-sort/problem
#!/bin/python3
if __name__ == '__main__':
# Get number of entries
nm = input().split()
n = int(nm[0])
m = int(nm[1])
# Create a list
arr = []
# Append N inputs to arr
for _ in range(n):
arr.append(list(map(int, input().rstrip().split())))
# Get attribute to inspect
k = int(input())
# Create a dictionary
attributeDict = dict()
# Iterate list
for row, elem in enumerate(arr):
# {Row: list}
# Accept index and kth number inside the list
attributeDict[row] = elem[k]
# Sort dictionary by values, instead of key
for key, value in sorted(attributeDict.items(), key=lambda x:x[1]):
print(' '.join(str(i) for i in arr[key]))