./sort_ignore_case.py
# Example using sort with a key (criteria used to sort)
# Sara Sprenkle
words = ["Washington", "and", "Lee", "computer", "science"]
words.sort()
print("Words in Python str-standard sorted order:")
for word in words:
print(word)
print()
print("Words in sorted order, ignoring upper and lower case:")
# says the key being used to do the sorting: using the str class's
# lower() method.
words.sort(key=str.lower)
for word in words:
print(word)
# Note that the strings in the list did *not* change.
# Only the order changed.
Generated by GNU Enscript 1.6.5.90.