Posted on 2007-12-04 18:48
ZelluX 阅读(1096)
评论(0) 编辑 收藏 所属分类:
Scripting
lambda真是王道啊
#!/usr/bin/env python
d={'a':1,'b':5,'c':4}
print sorted(d.items(), key=lambda (k,v): (v,k))
Help on built-in function sorted in module __builtin__:
sorted(...)
sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list