4
$\begingroup$

I have associations look like this:

data = {<|a -> {2, l1}, b -> {3, l1}|>, <|a -> {3, l2}, b -> {2, l2}|>}

I want the result:

<|a -> {3, l2}, b -> {3, l1}|>

The bigger digit of first value should be left.

$\endgroup$

1 Answer 1

4
$\begingroup$
Merge[data, First @* MaximalBy[First]]
<|a -> {3, l2}, b -> {3, l1}|>
$\endgroup$
1
  • $\begingroup$ I think too much about Union. $\endgroup$
    – erow
    Commented Jun 14, 2017 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.