27 lines
667 B
Python
27 lines
667 B
Python
#!/usr/bin/env python
|
|
"""Sort titles, ignoring leading articles"""
|
|
books = [
|
|
"A Study in Scarlet",
|
|
"The Sign of the Four",
|
|
"The Hound of the Baskervilles",
|
|
"The Valley of Fear",
|
|
"The Adventures of Sherlock Holmes",
|
|
"The Memoirs of Sherlock Holmes",
|
|
"The Return of Sherlock Holmes",
|
|
"His Last Bow",
|
|
"The Case-Book of Sherlock Holmes",
|
|
]
|
|
|
|
|
|
def strip_articles(title): # <.>
|
|
title = title.lower()
|
|
for article in 'a ', 'an ', 'the ':
|
|
if title.startswith(article):
|
|
title = title[len(article):] # <.>
|
|
break
|
|
return title
|
|
|
|
|
|
for book in sorted(books, key=strip_articles): # <.>
|
|
print(book)
|