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?

More than 5 years have passed since last update.

忘備録 リストの並び替えについて

Posted at

#忘備録ですがリストの並び替えについて

lst.sort(key = lambda x:x[0])
→0番目の要素でソートする

lst.sort(key = lambda x:(x[0],x[1]))
→0番目の要素でソートしてから1番目の要素でソートする

lst.sort(key = lambda x:(x[0],x[1]),reverse = True)
とreverseを付けることで逆順にしたりしなかったりできる。

にしてもlambda式まだ全然よくわかっていないから毎日↑の並び替え書いて暗記するしかないかなぁ。

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