# Chris Pine tutorial assistance chapter 7 sort data without use of .sort method

**URL:** <https://www.ruby-forum.com/t/chris-pine-tutorial-assistance-chapter-7-sort-data-without-use-of-sort-method/154066>\
**Category:** Ruby\
**Created:** [November 25, 2008, 12:26am UTC](https://www.ruby-forum.com/t/chris-pine-tutorial-assistance-chapter-7-sort-data-without-use-of-sort-method/154066 "2008-11-25T00:26:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 25, 2008, 12:26am UTC](https://www.ruby-forum.com/t/chris-pine-tutorial-assistance-chapter-7-sort-data-without-use-of-sort-method/154066/1 "2008-11-25T00:26:00Z")

</div>

I’m learning to program and came across Chris P.'s Ruby Tutorial.

I’ve got to the Array and Iterators chapter (  
[http://pine.fm/LearnToProgram/?Chapter=07](http://pine.fm/LearnToProgram/?Chapter=07)  
).

and the following assignment " Let’s write a program which asks us to  
type in as many words as we want (one word per line, continuing until  
we just press Enter on an empty line), and which then repeats the  
words back to us in alphabetical order. OK? "

\*\*\*\*\*\* HOWEVER I’m not allowed to use the .sort method \*\*\*\*\*\*\*\*

The covered chapters (1 ~ 7) have not covered method creation,  
Classes, Blocks or Procs, so the challenge is to solve the assignment  
without using them ( which is dandy since I don’t know what they are  
and I want to solve this assignment before I move forward to discover  
what they are).

This is what I’ve come up with so far, however when run… It’s not  
working - surprise surprise.

Could someone initially give me an idea of what is going wrong rather  
than rectify my code.

puts ‘Type in as many words as you want and once you've had enough,  
just 'enter' a clear line.’

words\_array = []

loop do  
input = gets.downcase.chomp  
break if input.empty?  
words\_array \<\< input

end

wordCheck = words\_array.last  
rotateCounter = 0  
sortedWords\_array = []  
until words\_array.length == 0  
while rotateCounter \<= words\_array.length  
if words\_array[0] \>= wordCheck

```
                   words_array.push words_array.shift
                   rotateCounter = rotateCounter + 1

           else wordCheck = words_array[0]
                   rotateCounter = 0
           end

   end
   sortedWords_array.push wordCheck

   until wordCheck = words_array.last
           words_array.push words_array.shift
   end
   words_array.pop
   rotateCounter = 0
   wordCheck = words_array.last

```

end  
puts sortedWords\_array

# Any help greatly appreciated
