Greg Barozzi wrote: > George George wrote: >> Given an array of arrays for example >> [["A", "B"], ["A", "B", "D", "C"], ["B", "D"], ["B", "C", "F", "E"], >> ["C", "F"], ["C", "E"], ["G"]] >> >> what would be a nice way of "merging" the items that seem to already be >> contained in another array. > > Try this: > > arr = [["A", "B"], ["A", "B", "D", "C"], ["B", "D"], ["B", "C", "F", > "E"], > ["C", "F"], ["C", "E"], ["G"]] > > > arr = arr.flatten.sort > > str = arr.to_s.squeeze > > arr = str.split(//) > > > This takes the array of arrays, flattens it into a single array > and sorts it. Then turns it into a string so we can use the > squeeze method that eliminates duplicate characters. Then > it changes it back into an array. =) Well, this will just yield the discrete strings -- not what the OP asked. But what you're talking about can be done more efficiently with arr.flatten.uniq.sort . No need for the intermediate string representation. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen / marnen.org -- Posted via http://www.ruby-forum.com/.