I finally have had more success, at least for the first part of the
exercise. Thanks for all the help. I do have another question (will
they ever stop) - in my code below as in Matthew's example the
array.push doesn't take place till after the loop is exited.  Why is
that, can't they be added incrementally ?  I did the array.push in the
loop and it completely skipped over it, or seemed to at least.


def sort words

  u_words = []
  s_words = []

  continue = true
  while continue
  puts words
  userword = gets.chomp.downcase
  u_words.push(userword)
  puts 'we now have these words in our list '
  puts u_words
  puts 'shall we continue?'
  a = gets.chomp.downcase
    if a == 'yes'
      continue = true
            else
              continue = false
            end
            puts 'we now have these words in our list '
  puts u_words
    end
end
  sort 'Please enter a word for sorting'

I have a ways to go to complete this little tiny project but I must
not use array.sort.

Stuart

On 6/26/06, Matthew Smillie <M.B.Smillie / sms.ed.ac.uk> wrote:
> On Jun 26, 2006, at 20:24, Dark Ambient wrote:

> def sortwords
>    words = []
>    continue = false
>    while continue
>      word = gets.chomp.downcase
>      if word == 'stop'
>        continue = false
>      elsif word == 'hello'
>        # or some other special case.
>        puts "hello yourself"
>      else
>        # default behaviour
>        words.push(word)
>      end
>    end
>    return words.sort
> end
>
> sortwords # (input 'foo', 'bar', 'baz', 'stop')
> => ["bar", "baz", "foo"]
>
>
> matthew smillie.
>
>