I am having a List
of Tuples
which contains some data and the last element of each tuple is a Map
. Now, i want to remove duplications and find the unique values by maximum value %{u: [{_, _, value}]}
in the map.
[
{"Elixir", 2019,
%{
values: %{u: [{:b, :r1, 1}]},
status: true
}},
{"Elixir", 2020,
%{
values: %{
u: [
{:b, :r2, 1},
{:b, :r3, 2}
]
},
status: true
}},
{"Elixir", 2020,
%{
values: %{
u: [
{:b, :r2, 2},
{:b, :r3, 2}
]
},
status: true
}}
]
The final output should look like
[
{"Elixir", 2019,
%{
values: %{u: [{:b, :r1, 1}]},
status: true
}},
{"Elixir", 2020,
%{
values: %{
u: [
{:b, :r2, 2},
{:b, :r3, 2}
]
},
status: true
}}
]
So it also removed the duplicated {elixir, 2020}
and left behind the tuple having the maximum value of 2.
I tried it using groups but I don’t how to go inside the maps and then compare two different tuples.
Thanks