k = input()
stud = []
while k != 'end':
stud.append([float(s) for s in k.split(' ')])
for i in range(len(stud) - 1):
for j in range(i + 1, len(stud)):
if stud[i][1] > stud[j][1] or (stud[i][1] == stud[j][1] and stud[i][0] < stud[j][0]):
stud[i], stud[j] = stud[j], stud[i]
for i in range(len(stud)):
print(f'{stud[i][0]:.2f} {stud[i][1]:.3f}')
Объяснение:
k = input()
stud = []
while k != 'end':
stud.append([float(s) for s in k.split(' ')])
k = input()
for i in range(len(stud) - 1):
for j in range(i + 1, len(stud)):
if stud[i][1] > stud[j][1] or (stud[i][1] == stud[j][1] and stud[i][0] < stud[j][0]):
stud[i], stud[j] = stud[j], stud[i]
for i in range(len(stud)):
print(f'{stud[i][0]:.2f} {stud[i][1]:.3f}')
Объяснение: