From: Greg Willits Date: 2012-04-21T01:55:36+09:00 Subject: Re: finding duplicates in an array and its index number Greg Willits wrote in post #1057552: > I do a lot of indexing of data. Usually they're multi-field records, and > each data set will have multiple indexes. The technique I use is below. > This indexes all elements of the array. So, then to find duplicates, you > have to loop again to find array counts > 1. Anyway, it's a slightly > different way to do it in the event an index of all entries would be > useful for lookups. DOH. That first loop only needed to be: data.each_with_index do |value, indx| if !dataIndex.has_key?(key) dataIndex.store(key, []) end dataIndex[key].push(value) end That's what I get for doing a quick transcribe of project code. -- gw -- Posted via http://www.ruby-forum.com/.