I'm trying to turn a sequence of maps, like for instance
val input = Seq(Map("a" -> 1, "b" -> 2),
Map("a" -> 10, "c" -> 30),
Map("b" -> 200, "c" -> 300, "d" -> 400))
into a map from the keys in those maps to the sequence of values they map to across each of the maps in the original sequence.
So the above should transform into
val output = Map("a" -> Seq(1, 10),
"b" -> Seq(2, 200),
"c" -> Seq(30, 300),
"d" -> Seq(400))
I can think of a few ways to go about this but I'm looking for a solution that is idiomatic or the best scala style for this sort of transformation? Ideally without being really wasteful but performance isn't a great concern.
Thanks!