From: "James H." Date: 2012-07-25T15:19:20+09:00 Subject: Re: Help with exercise from Chris Pine's Ruby Book: Sort without using .sort Hello Jan E., Thank you very much for your help and crystal clear explanation. My misunderstanding of how variables work was the root cause of my confusion. Based on your advice building the recursive version of the sort only took me a few minutes. I really appreciate you taking the time to answer my questions. James My recursive sort: (ugly I'm sure) def sort_wrap arr sort_meth arr, [] end def sort_meth unsorted, sorted if unsorted.length == 0 return sorted end new_unsorted = [] smallest = unsorted.pop unsorted.each do |testword| if testword < smallest new_unsorted.push smallest smallest = testword else new_unsorted.push testword end end sorted.push smallest unsorted = new_unsorted sort_meth new_unsorted, sorted end puts (sort_wrap(['beta', 'zeta', 'alpha', 'depha', 'cina', 'emma', 'bonny', 'falco'])) -- Posted via http://www.ruby-forum.com/.