Sort the books alphabetically. Remember: you cannot place a larger book on top of a smaller one, and you can only move one book at a time.
Restart