Posts

Showing posts from December 6, 2018

Min and Max of a list of Associations

Image
up vote 3 down vote favorite I am trying to find the minimum values for all elements in a list of associations, below is an example x = {<|"a"-> 4, "b"->9, "c"->15|>, <|"a"->21, "b"->11, "c"->1|>, <|"a"->12, "b"->3, "c"->21|>} Required output for Min {<|"a"-> 2, "b"->3, "c"->1|>} Required output for Max {<|"a"-> 21, "b"->11, "c"->15|>} My attempt for Max: MaximalBy[Values]@x Result: {<|"a" -> 21, "b" -> 11, "c" -> 1|>} for Min: MinimalBy[Values]@x Result: {<|"a" -> 4, "b" -> 9, "c" -> 15|>} Is