From: "Jesús Gabriel y Galán" Date: 2012-02-06T17:43:43+09:00 Subject: Re: Difficulty writing a sorting method (Chris Pine's Learn to Program) On Fri, Feb 3, 2012 at 11:56 PM, claire pengelly wrote: > Hi all, I'm very, very new to programming and have been working through > Chris Pine's book. Welcome to Ruby, I hope you enjoy it ! > The assignment I'm working on is to write a sorting > method without just using .sort or recursion. It should sort a list of > words alphabetically. Here is what I have so far: > #get list of words > puts "Hello, type as many words as you want, with one word per line!" > > words = [] > already_sorted = [] > unsorted = [] > while true >   word = gets.chomp.capitalize >   if word == '' >    break >   end > end > > words.push word There's a problem here. You are pushing the word into the array outside of the while true loop. This means that when you type a word a press enter, that word is lost. This goes on until you input an empty line, which triggers the break. Then you push that word in the array, but as you have checked that word is the empty string. So you should put the push inside the loop, after checking for the empty string. As Randy has pointed out, there are probably other problems down the line, but try to fix this one so you can move forward, and let us know how you fare. Good luck ! Jesus.