From: Daniel Lucraft Date: 2007-07-19T18:40:20+09:00 Subject: Re: confused, need help with a sorting program Sebastian Hungerecker wrote: > Daniel Lucraft wrote: >> Sebastian Hungerecker wrote: > Yeah, seems I didn't read the code carefully enough. I only focussed on > the > part that I quoted. I actually wrote that post twice over :-). I spend too much time here... >> the original array isn't sorted, but >> cleared out by this code, since he's calling unsorted_array.pop at each >> level. > > But before it pops, it actually does sort the unsorted array in the > 0.upto > part, doesn't it? Yep. If it wasn't popped but just took the last element (and kept track of you place), you'd end up with a new array that was sorted correctly, and the original array would be sorted in place, in reverse. This is all very verbal. Recursion is one of those things you have to expend an enormous amount of words to make your meaning understood. best, Dan -- Posted via http://www.ruby-forum.com/.