The Library Sorter

Challenge: Sort by Title

Sort the books alphabetically by their title.

Book Class:

class Book:
  def __init__(self, title, author, year):
    self.title = title
    self.author = author
    self.year = year

Unsorted Books

  • The Lord of the RingsJ.R.R. Tolkien (1954)
  • The HobbitJ.R.R. Tolkien (1937)
  • 1984George Orwell (1949)
  • Animal FarmGeorge Orwell (1945)

Sorted Books (Your result)

    Python Editor

    Write the `sort_books(books)` function to return a list of the book *titles* sorted correctly.