小编raj*_*v90的帖子

如何根据子列表的长度对列表进行排序

我有以下清单

a = [['a', 'b', 'c'], ['d', 'e'], ['f', 'g', 'h'], ['i', 'j', 'k', 'l'], ['m', 'n'], ['o']]
Run Code Online (Sandbox Code Playgroud)

我想根据子列表的长度对列表进行排序.结果应该是:

a = [['o'],['d','e'],['m', 'n'],['a', 'b', 'c'],['f', 'g', 'h'], ['i','j','k','l']]
Run Code Online (Sandbox Code Playgroud)

python list python-2.7

17
推荐指数
2
解决办法
2万
查看次数

标签 统计

list ×1

python ×1

python-2.7 ×1