python 3.5 偏函数实现忽略大小写排序
import functools import operator L = ['bob', 'about', 'Zoo', 'Credit'] sorted_ignore = functools.partial(sorted,key=functools.cmp_to_key(lambda x,y:operator.eq(x.upper(),y.upper()))) print(sorted_ignore(L))
import functools import operator L = ['bob', 'about', 'Zoo', 'Credit'] sorted_ignore = functools.partial(sorted,key=functools.cmp_to_key(lambda x,y:operator.eq(x.upper(),y.upper()))) print(sorted_ignore(L))
2018-08-17
举报