Skip to content

Instantly share code, notes, and snippets.

@wflanagan
Last active April 7, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wflanagan/bdd9718aafdc85b9691c839bcf96550e to your computer and use it in GitHub Desktop.
Save wflanagan/bdd9718aafdc85b9691c839bcf96550e to your computer and use it in GitHub Desktop.
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
@ttigerboy
Copy link

Cool code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment