您可以使用list.sort http://docs.python.org/3/library/stdtypes.html#list.sort, its 按键功能 http://docs.python.org/3/glossary.html#key-function, and operator.itemgetter http://docs.python.org/3/library/operator.html#operator.itemgetter:
>>> from operator import itemgetter
>>> example = [['b',1],['b',2],['a',2]]
>>> example.sort(key=itemgetter(1,0))
>>> example
[['b', 1], ['a', 2], ['b', 2]]
>>>
您还可以使用lambda http://docs.python.org/3/tutorial/controlflow.html#lambda-expressions代替operator.itemgetter
:
example.sort(key=lambda x: (x[1], x[0]))
但那样会慢一些。