Hi all,
I have several arrays in these format:
a=[
[10,2,3,2012,],
[20,3,4,2012],
[3,4,5,2012],
]
b=[
[1,2,3,2013,],
[2,3,4,2013],
[3,4,5,2013],
]
c=[
[2,3,4,2014],
[4,5,6,2014],
[5,6,7,2014],
]
d=a+b+c
By definition 1) [3,4,5,2012] and [3,4,5,2013] are duplicated,
2) [2,3,4,2013] and [2,3,4,2014] are also duplicated
and the rule is that elements will be considered duplicated if the
first two columns in each element are identical
I know I can use this line to get the unique elements if I only filter
by one column: d.uniq!{|array|array[0]}
But this time my filter conditions are based on array[0] and array[1],
how can I write a code line to achieve this purpose?
Also I want to keep the elements from 2013 only after removing
duplicates, how can I do that? e.g., [3,4,5,2012] and [3,4,5,2013] are
duplicated, keep [3,4,5,2013] after removing duplicate ;
[2,3,4,2013] and [2,3,4,2014] are duplicated, keep [2,3,4,2013] after
removing duplicate.
Thanks in advance.