LoginSignup
0
1

More than 3 years have passed since last update.

[python] sorted()やsort()でソート条件を指定する

Last updated at Posted at 2021-04-16

lambda式を使う

l_2d = [[2, 10], [1, -30], [-3, 20]]
print(sorted(l_2d, key=lambda x: x[1], reverse=True))
# [[-3, 20], [2, 10], [1, -30]]

max()などの関数でも使える。

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