initial creation
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user