python データの並び替え

scores = [
{“name”: “Taro”, “math”: 70, “english”: 82},
{“name”: “Jiro”, “math”: 67, “english”: 61},
{“name”: “Saburo”, “math”: 81, “english”: 58},
]

print(“Name Math English”)
print(“——– ——– ——–“)

scores.sort(key=lambda score: score[“math”], reverse=True)

for score in scores:
for value in score.values():
print(f”{value:8} “, end=””)
print()

python データ

scores = [
{“name”: “Taro”, “math”: 70, “english”: 82},
{“name”: “Jiro”, “math”: 67, “english”: 61},
{“name”: “Saburo”, “math”: 81, “english”: 58},
]

print(“Name Math English”)
print(“——– ——– ——–“)

for score in scores:
for value in score.values():
print(f”{value:8}”, end=””)
print()