1.忽略字母大小写,进行(abc)排序
def cmp_ignore_case(s1,s2):
s1 = s1.lower() #or s1 = s1.upper()
s2 = s2.lower() #or s2 = s2.upper()
if s1 < s2:
return -1
if s1 > s2:
return 1
return 0
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
关于sorted函数
sorted(['ajc','xbjhg','bhj','sxh']) #['ajc', 'bhj', 'sxh', 'xbjhg']
sorted([10,5,9]) #[5, 9, 10]