From: William James Date: 2008-11-29T08:29:59+09:00 Subject: Re: Programming Noob Chris Pine Tutorial sorting without use of array.sort method On Nov 27, 5:22 pm, Todd Benson wrote: > Cheating... > > a = my_word_array > sorted = [] > while !a.empty?; sorted << a.delete(a.min); end Fails when there are duplicates. a = %w(one two three two four) sorted = [] while !a.empty?; sorted << a.delete(a.min); end p sorted Try this: ary = %w(bubble sort is so cute and quaint and slow and it's so simple that even I can remember the algorithm) swapped = true while swapped do swapped = false (ary.size-1).times{|i| if ary[i] > ary[i+1] ary[i,2] = ary[i,2].reverse swapped = true end } end p ary