On Jun 29, 2006, at 6:53 PM, Dark Ambient wrote: > On 6/29/06, James Edward Gray II <james / grayproductions.net> wrote: > > This line (following) is the one that hung me. > >> if lowest == nil || item < lowest > > After many iterations of various attempts, embarassingly I picked the > worst and most incomplete to post. I get it now somewhat, though the > 'aha!' moment is still not hitting. I'll attempt to analyze. Your > looking for the item that is smaller (or less then) then nil. How can > any of the items be smaller then nil ? Nope we're not comparing anything with nil. This code handles the very first comparison, where we always want to take the item, because it's the only thing we've seen and therefore must be the lowest. To handle that, I initialize lowest to nil and then replace lowest if it's still nil (first item check), or the new item is lower (all other checks). >> # make a new unsorted list, minus the low guy >> new_unsorted = [ ] >> added = false >> unsorted.each do |item| > > item == lowest meaning that there was already something assigned to > lowest ? > >> if added == false and item == lowest >> added = true >> else >> new_unsorted.push(item) >> end >> end Yes, the code earlier ensures that we have the lowest item. Now I'm just copying the list and skipping the first occurrence of that item, since we moved it to the other list. > It helps yes, thank you very much. Wish I would have came up with it > myself. You will improve. It comes with practice, I promise. Keep at it. We all started where you did! James Edward Gray II