Hi,
I am having a map from which I want to extract values by the maximum length of values.
map =
%{
"A" => [
{:b, "B", 1},
{:b, "C", 1}
],
"B" => [
{:b, "D", 1}
],
"C" => [
{:b, "E", 1},
{:b, "F", 1}
]
}
Here is my code:
Enum.max_by(map, fn {key, value} -> length(value) end)
which gives me
{"A", [{:b, "B", 1}, {:b, "C", 1}]}
while I need to get a list of both key values that have maximum values. In this case, this should be the output
[
{"A", [{:b, "B", 1}, {:b, "C", 1}]},
{"C", [{:b, "E", 1}, {:b, "F", 1}]}
]