From: "Thairuby ->a, b {a + b}" Date: 2009-09-26T19:18:54+09:00 Subject: Re: How to remove duplicate elements in a 2D array The main idea is to use Hash and use the first letter ("a","b","c") as a key. I do it with "inject" and David do it with "Hash[]" I change your arr arr=[[ 'a',1,2,3], ['b',4,5,6], ['c',3,2,1], ['a',1.3,2.2,3,3], ['a', 2,1,3], ['a',2.1,1.5,3]] to a hash hash={'a'=>[1,2,3], 'b'=>[4,5,6], 'c'=>[3,2,1], 'a'=>[1.3,2.2,3,3], 'a'=>[2,1,3], 'a'=>[2.1,1.5,3]} You can see that key "a" does repeat 4 times in hash. So, the last one will replace the first one automatically. finally, hash = {"a"=>[2.1, 1.5, 3], "b"=>[4, 5, 6], "c"=>[3, 2, 1]} The method ".map(&:flatten)" is use to converse hash back to array. -- Posted via http://www.ruby-forum.com/.