Rite of Passage: Sorting
Remember the sorting program you wrote here where you asked for a list of words, sorted it, and then displayed the sorted list? The program was made much easier because you used the array’s sort method. But, like the Jedi who constructs their own lightsaber, you’ll demonstrate a deeper mastery if you write your own sorting method. It’s not easy, but this kind of problem solving is part of nearly every program you’ll write. We’ve all done it, and now you will, too.
But where do you begin? Much like with continent_size, it’s probably best to try to solve the problem in English first. You can then translate it into Ruby after you’ve wrapped your head around it.
So, you want to sort an array of words, and you know how ...
Get Learn to Program, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.