Professional Documents
Culture Documents
Chapter 06
Chapter 06
1 Custom sorting def compareNumOfChars(string1, string2): return cmp(len(string1), len(string2)) wordList = ['Python', 'is', 'better', 'than', 'C'] wordList.sort() print wordList wordList = ['Python', 'is', 'better', 'than', 'C'] wordList.sort(compareNumOfChars) print wordList