From: Mill Mill Date: 2005-07-21T18:39:32+09:00 Subject: Re: List of removed items using Array#uniq Mill Mill gmail.com> writes: > > duplicates = all.uniq.select{|x|all.select{|y|y==x}.size>1} > duplicate_with_count = all.inject(Hash.new(0)){|n,x|n[x]+=1;n}.select{|k,v|v>1} > > hope this helps. > > -mill > > and this maybe better too: duplicates_with_count=Hash.new(1) s=all.sort s.each_index{|i| duplicates_with_count[s[i]]+=1 if s[i]==s[i-1]}