Chuck Remes wrote: > (And Joel, I have presorted the array prior > to removing the dupes so I have already taken care of the ordering > issue.) That's well and good, but in the process of using a hash to remove the duplicates, the result will be out of order. See example below. > > I was trying to figure out how to use a hash but did not > make the leap to the ||= construction on my own. > A simple if statement will achieve the same result: a = [ [1, 2, 3, 10], [1, 2, 3, 20], [1, 2, 3, 30], [2, 2, 3, 40] ] h = {} a.each do |suba| key = suba.slice(0, 3) if h[key] next else h[key] = suba end end p h.values --output:-- [[2, 2, 3, 40], [1, 2, 3, 10]] -- Posted via http://www.ruby-forum.com/.