Methods, Blocks, & Sorting


If we were to hand you five books and ask you to arrange them, sorted by title, on a shelf, how would you do it?

Most sorting algorithms assume we are sorting an array of items, which involves comparing any two items in the array and deciding which should come first.

For our books example, if for any pair we always chose the book whose title came first in the alphabet, we could devise a strategy for sorting. These "strategies" are the sorting algorithms mentioned in the previous example. Our job is to decide how to compare two items in the list, and let Ruby decide which strategy to use.

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.