Methods, Blocks, & Sorting
Introduction to Sorting

Sorting arrays is a very common problem in computer science, and is well studied for that reason. There are many algorithms —well-defined sequences of steps—each with its own trade-offs and advantages.

Sorting algorithms can be a great introduction to computer science as a theoretical discipline, but for now we’ll focus on how to use Ruby’s built-in sorting library (which implements a few of these algorithms).



Use the .sort! method to sort the values in my_array. Magic, isn’t it?

Display my_array in the console.

Folder Icon

Take this course for free

Already have an account?