From: Jano Svitok Date: 2007-11-20T04:34:44+09:00 Subject: Re: One for me as a noob hard task On Nov 19, 2007 8:22 PM, Sebastian Hungerecker wrote: > Joakim Olsson wrote: > > and which then repeats the words back to us in alphabetical order > > without using the sort method. It says I shall do it at > > http://pine.fm/LearnToProgram/?Chapter=07 but I'm stuck. > > http://en.wikipedia.org/wiki/Sorting_algorithm#Summaries_of_popular_sorting_algorithms > Pick one (bubble sort is quite easy) and then implement it in ruby. Or for the beginning, before you try to implement any of those algorithms, you may try this: Just image how YOU would sort a pile of cards with those words on them. What would you do? Then try to implement it in ruby. The pile is your array. You may (or not) need another pile, and some basic operations: remove a card from the stack, and insert it in some other place, and maybe more. You don't have to make it fast, or efficient. Just try to make it work anyhow. If you're stuck, try with small arrays - the smallest one is empty ;-) It's easy to sort an empty array, right? Then try one word. Still easy. Two words? Three? Four? After you have done this, look at the "properly designed" algorithms and try to implement some of them. Finally you can more-or-less forget about this all and use the sort method ;-) It's always good to know what's going on under the hood. Good luck! Jano