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()などの関数でも使える。
Go to list of users who liked
More than 3 years have passed since last update.
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()などの関数でも使える。
Register as a new user and use Qiita more conveniently
Go to list of users who liked