In [11]: a = ['a','abasdada','ab','acvv']
In [12]: a.sort(lambda x,y:cmp(len(x),len(y)))
In [13]: a
Out[13]: ['a', 'ab', 'acvv', 'abasdada']
In [11]: a = ['a','abasdada','ab','acvv']
In [12]: a.sort(lambda x,y:cmp(len(x),len(y)))
In [13]: a
Out[13]: ['a', 'ab', 'acvv', 'abasdada']
本文标题:list 里的字符串排序
本文链接:https://www.haomeiwen.com/subject/dcuazqtx.html
网友评论