Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- books = ["Charlie and the Chocolate Factory", "War and Peace", "Utopia", "A Brief History of Time", "A Wrinkle in Time"]
- books.sort! # sorts the books in place
- books = books.sort # sorts them, putting them back into the books variable.
- books = books.sort_by { |book| book.length } # sorts them into the length of their title, shortest first
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement