LoginSignup
1
1

More than 3 years have passed since last update.

sorted

Posted at
点数の低い順
ranking = {
    'A':100,
    'B':80,
    'C':95
}

print(sorted(ranking, key=ranking.get))
実行結果
['B', 'C', 'A']
点数の高い順
ranking = {
    'A':100,
    'B':80,
    'C':95
}

print(sorted(ranking, key=ranking.get, reverse=True))
実行結果
['A', 'C', 'B']
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1