From: Lars Haugseth Date: 2012-07-25T16:09:41+09:00 Subject: Re: Help with exercise from Chris Pine's Ruby Book: Sort without using .sort On 07/25/2012 09:01 AM, Jan E. wrote: > Your method is of course correct. But you don't really use the > recursion, since you basically just replaced the while loop with a > method repeatedly calling itself. > > You might want to reduce the problem to a smaller task first. For > example, you could write a method that finds the minimum of an array and > returns both the minimum and the rest of the array. You can then use > this simple method to recursively build a sorted array: Though that might defeat the purpose of the exersize, there already exists such a method, Array#min. If using Array#min (or some self-implemented version of min) is permitted, sorting can be done as simple as: sorted = unsorted.size.times.map { unsorted.delete unsorted.min } -- Lars Haugseth