Python Sort多值排序

假设使用lambda函数

s = sorted(s, key = lambda x: (x[1], x[2]))

如上所示,返回一个tuple,其中[0]是第1个排序key,[1]是第2个。

Leave a Reply

Your email address will not be published. Required fields are marked *