0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】pythonで辞書型のvalueでソートする.

Posted at

以下のような辞書があったとします。

height = {"太郎" : 179, "次郎" : 159, "三郎" : 190, "四郎" : 163}

この辞書のキーを用いて並べ替えを行う。

dict(soorted(height.items(), key = lambda x : x[1]))

また降順にするにはsorted関数の引数にreverseを持たせます。

dict(soorted(height.items(), key = lambda x : x[1], reverse = True))
0
0
2

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?