Start: Jul, 06, 2019 10:00:00
20190706Python程序设计基础培训扩展练习
End: Jul, 17, 2019 12:00:00
Time elapsed:
Time remaining:

Problem_ID: B
Result: Accepted
Time: 50ms
Memory: 25312kB
Author: 13858900561
In contest: 1300

def bubblesort(lst,func=lambda n:n):
    for i in range(len(lst)):
        for j in range(len(lst)-1,i,-1):
            if func(lst[j])>func(lst[j-1]):
                lst[j],lst[j-1]=lst[j-1],lst[j]
    

for i in range(int(input())):
    n=int(input())
    lst=[]
    for j in range(n):
        a,b=input().split()
        lst.append([a,int(b)])
        
    bubblesort(lst,func=lambda n:(n[1]))
    for cr in lst:
        for cl in cr[:-1]:
            print(cl)