MkyTaP - 開發筆記
主要工具: Linux, Python, SQL
Saturday, May 11, 2019
Python: sorted 2d list by element, reverse
要按第一個元素倒排, 第二個元素正排︰
sorted(lista, key=lambda x: (-x[0], x[1]))
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment