fork(13) download
  1. def x = [ [a:1, b:2], [a:1, b:3], [a:2, b:4] ]
  2. def y = [ [f:10, b:2, g:7], [f:100, b:3, g:8], [f:20, b:4, g:9] ]
  3. def mergmaps = { list -> def m = [:] ; list.collect{ m += it}; m }
  4. def result = (x + y).groupBy { it.b }.collect{it.value}.collect{mergmaps(it)}
  5. println result
Success #stdin #stdout 1.4s 2911744KB
stdin
Standard input is empty
stdout
[[a:1, b:2, f:10, g:7], [a:1, b:3, f:100, g:8], [a:2, b:4, f:20, g:9]]