Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn
Methods, Blocks, & Sorting

Foundations

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.

Report a Bug
If you see a bug or any other issue with this page, please report it here.