October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function is passed a string buffer. It splits the string into words and alphabetizes them. The return value is a list containing the words in alphabetical order.
For the purposes of alphabetizing them, strings are compared with the Python < operator, which compares strings using the built-in ord() function that winds up comparing them based on ASCII values. Thus, upper- and lowercase letters are unequal; the uppercase letters are considered “earlier” than the lowercase ones.
1. def alphabetize ( buffer ): 2. 3. """Split buffer into words and return a list of them 4. in alphabetical order. 5. 6. 7. """ 8. 9. ...
Read now
Unlock full access