jmpark0118 / CODING_TEST_PRACTICE

0 stars 0 forks source link

Practice>Python>Built-Ins>Athlete Sort #120

Open jmpark0118 opened 3 years ago

jmpark0118 commented 3 years ago

image image

출처 : https://www.hackerrank.com/challenges/python-sort-sort/problem

jmpark0118 commented 3 years ago

if __name__ == '__main__':
    n, m = map(int, input().split())

    arr = []

    for _ in range(n):
        arr.append(tuple(map(int, input().rstrip().split())))

    k = int(input())

    arr_sort = sorted(arr, key = lambda x: x[k])
    for i in arr_sort:
        print(*i)
jmpark0118 commented 3 years ago

if __name__ == '__main__':
    n, m = map(int, input().split())
    arr = [input() for _ in range(n)]
    k = int(input())

    for row in sorted(arr, key = lambda x: int(x.split()[k])):
        print(row)