What if we wanted to sort the books by title, but from Z – A, or descending order? It appears that Ruby’s sort method only works for A – Z, or ascending order.

The sort method assumes by default that you want to sort in ascending order, but it accepts a block as an optional argument that allows you, the programmer, to specify how two items should be compared.



Sort your books in descending order on line 8. Use the example of sorting in ascending order on line 4 as a guide.

Display the result in the console.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?