Comparing two lists

I’m a bit stuck here. I’m trying to compare list a (top) with b (middle) then I will be able to fetch the corresponding list item from list c (bottom). I’m quite new to Dynamo and haven’t been able to understand the solutions I’ve found, but it looks like maybe I should use a dictionary node?

List.Contains queries index 0 with the value “011” and compares to each item in list b, and finds no match. OK. But when List.Contains looks at index 1 with the value “226” I don’t understand why it doesn’t see that list b contains “226” at index 5.

(PS I’m trying to stick to OOTB nodes for now until I understand what I’m doing more)

1 Like

This is what the dictionary node is perfect for. use List B as the keys and List C as the values, then plug List A into the dictionary.getvalue node and the values coming out will be the list you are trying to find

hi @jp2982 I’ll start reading a bit more about dictionaries. but maybe something else is wrong here? Take a look at this graph. Here it works as I’m expecting. But I can’t work out what the difference is. I even ran the IsHomogeneous node on a merged list to check that everything is of the same type in each list - and found no problem.

Please take a look at this graph and see if it helps. You can simplify out code block and list filter if you sure that every value in list B has a match in list A.

1 Like

image
like this??

@duncan.lithgow
Using a dictionary

@salvatoredragotta & @stillgotme they look like great solutions, thanks. I look forward to having a chance to try them in the coming days (a bit busy just now). It sure looks like dictionaries are useful.