Comparing two lists of unequla numbers to determine which items are different

As the title says. I am having some difficulties comparing list A with list B to determine the differences between each list. In the image below, the list are exactly the same except that list A had (4) items with the value of 269732 and list B has (5) items with the value 269732. What I want to happen is to compare the lists and get a result stating that the differences between the lists is a single value of 269732. I have tried useing Set.Difference but keep getting empty lists as a result. Even when switching the lacing, I do not get the expected result.

Any ideas on how to approach this?

Are both list the same Object.Type?

yes, they are both lists of strings.

Hi @eklinger ,

I am not at a pc right now but i’m sure the node CountOccurences from the Clockwork package will be useful

If they are both string i’m not sure why the SetDifference would not work. Maybe try trimming white space?

Hi not sure but how about something…

I gave it a shot with no luck. It looks as though the SetIntersection node returns a list of only the unique intersections from each list. Meaning, it does not return a list with multiple values of the same item, if they exist. I suspect that this might be part of the issue, but I am not sure how to approach it? Just to clarify, one list input into List.join has (5) items with the value of 269732 and the other has (3) values of 269732 but the resulting SetIntersection only lists (1)

Can’t you just convert the strings to numbers via String.ToNumber, sort them and then use == to compare them? Thats what I would do.

Hi @eklinger ,

See if the following works for you:


2023-01-30 Return amount of items that occur in second list.dyn (14.8 KB)

This should work in the context of the example you provided, assuming that both lists contain the same amount of unique items. If that is not the case you would have to expand a bit on my code.

PS: @leonard.moelders that wouldn’t work in this case, since both lists are not equal in length.

Python makes it really easy to count the number of occurrences. Along with the unique set, this allows you to create a simple dictionary pretty easily, regardless of number of items in any list.


Right now I’m showing the difference in counts between list items, but you could also have it return only the missing or mismatched counts as well.