为什么要小的放前面 为什么最后还有个return 0?
def cmp_ignore_case(s1, s2): u1=s1.upper() u2=s2.upper() if u1 < u2: return -1 if u1 > u2: return 1 return 0 print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
def cmp_ignore_case(s1, s2): u1=s1.upper() u2=s2.upper() if u1 < u2: return -1 if u1 > u2: return 1 return 0 print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
2017-03-06
举报