Contents

  1. sort_ignore_case.py

sort_ignore_case.py

# Example using sort with a key
# 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 (or the criteria) to use to do the sorting: 
# using the str class's lower() method.
words.sort(key=str.lower)

for word in words:
    print(word)

Generated by GNU Enscript 1.6.6.