From: Lars Haugseth Date: 2012-06-30T22:24:21+09:00 Subject: Re: stack level too deep for quicksort code On 06/30/2012 03:09 PM, Jan E. wrote: > Lars Haugseth wrote in post #1066738: >> The only time the array is referenced later in the method is when you >> partition all except the first element, so it makes perfect sense to me. > > I'm talking about the original array you want to sort. When you pass it > to the method, it will lose its first element: > > my_array = [3, 1, 5, 2] > sorted = quicksort(my_array) # get a sorted copy > p my_array # WTF? my_array has suddenly become [1, 5, 2] > > I'd actually call this a bug. The method should either sort the original > array, or it should not touch the original array at all and only return > a new sorted array. I think the second option makes more sense for a > function style method. > > But your method would return a new sorted array and at the same time > somewhat corrupt the original one. Ah, now I see what you mean. Good call. -- Lars Haugseth