我有一组哈希值,我需要根据哈希值之间的一个匹配值来查找和存储匹配项。
a = [{:id => 1, :name => "Jim", :email => "jim@jim.jim"},
{:id => 2, :name => "Paul", :email => "paul@paul.paul"},
{:id => 3, :name => "Tom", :email => "tom@tom.tom"},
{:id => 1, :name => "Jim", :email => "jim@jim.jim"},
{:id => 5, :name => "Tom", :email => "tom@tom.tom"},
{:id => 6, :name => "Jim", :email => "jim@jim.jim"}]
所以我想回来
b = [{:id => 1, :name => "Jim", :email => "jim@jim.jim"},
{:id => 3, :name => "Tom", :email => "tom@tom.tom"},
{:id => 5, :name => "Tom", :email => "tom@tom.tom"},
{:id => 6, :name => "Jim", :email => "jim@jim.jim"}]
注意:我可以事后对数据(csv)进行排序,:name
这样它们就不必很好地分组,只要准确即可。也不必两个相同,可以是 3 个或 10 个或更多。
此外,数据约为 22,000 行。