From: Roger Braun Date: 2010-01-23T17:16:47+09:00 Subject: Re: Sorting Method Hi, On Fri, Jan 22, 2010 at 8:45 PM, Tim Pollard wrote: > So I guess now my question is twofold: how do I include my initial > array assignments and the input = gets.chomp method without them > looping? Just don't put the input part into your recursive method. Do the input first, then sort it. > Finally, using parameters to call the method: My initial problem was, > I suppose, that I expected parameters to be neatly defined. Using the > factorial example, method_factorial (n) just didn't make sense to me > because I thought that n would have to be a static number (rather than > whatever is written after method_factorial). So, I think that sheds > some light on my wrapper question too--by having a wrapper it would > allow me to call the recursive method with only one parameter instead > of two, correct? Yes, that's right. > > I just don't understand what my program is supposed to do it I > arbitrarily write, say: > > recursive_sort 418, 958 The recursive sort method is supposed to the same as a regular sort method: Sort one array. irb(main):003:0> unsorted = [545,3,23435,2,68,4,4,234] => [545, 3, 23435, 2, 68, 4, 4, 234] irb(main):004:0> recursive_sort(unsorted) => [2, 3, 4, 4, 68, 234, 545, 23435] This is an example of a recursive sort. Both the resursive_sort_helper and insert_into_sorted are written in a recursive style. What this means is that both call themselves in their method bodies. http://pastie.org/790990 -- Roger Braun http://yononaka.de roger.braun@student.uni-tuebingen.de