Hi,there: The document of Python.org[http://docs.python.org/library/stdtypes.html] says that: ------------------------------------------------------------------------------------------------------------------ s.sort([cmp[, key[, reverse]]])
8. The sort() method takes optional arguments for controlling the comparisons. cmp specifies a custom comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether the first argument is considered smaller than, equal to, or larger than the second argument: cmp=lambda x,y: cmp(x.lower(), y.lower()). The default value is None. key specifies a function of one argument that is used to extract a comparison key from each list element: key=str.lower. The default value is None. reverse is a boolean value. If set to True, then the list elements are sorted as if each comparison were reversed. -------------------------------------------------------------------------------------------------------------------- I can understand how to use parameters of cmp and reverse,except the key parameter... Would anyone give me an example of using sort method with key parameter? Thanks! -- ph4...@gmail.com Mak Twilight _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor