Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. books = ["Charlie and the Chocolate Factory", "War and Peace", "Utopia", "A Brief History of Time", "A Wrinkle in Time"]
  2. books.sort! # sorts the books in place
  3. books = books.sort # sorts them, putting them back into the books variable.
  4. 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