Assuming I have list of maps in Groovy:
def listOfMaps = [
[k: 1, n: 'Name1', d1: 'a', d2: 'b'],
[k: 2, n: 'Name2', d1: 'c', d2: 'd'],
[k: 1, n: 'Name3', d1: 'e', d2: 'f'],
[k: 4, n: 'Name4', d1: 'g', d2: 'h']]
I need to find if there exist (or not) items, where k
is equal, but n
is not. E.g. in this case we have two map records with "k" = 1 and "n" is 'Name1' and 'Name3'. How can I find such data?
I suppose I should group by "k" and count distinct values in "n", if there are more than 1 unique values in "n" for certain "k" - we found such data.
I'm completely stuck so any help will be appreciated.
Thanks