# Comparing Lists - Return Common

**URL:** <https://forum.dynamobim.com/t/comparing-lists-return-common/68696>\
**Category:** Lists-Logic\
**Created:** [September 29, 2021, 1:20pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696 "2021-09-29T13:20:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmayesP84R8](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jmayesp84r8/32/120483_2.png) [@jmayesP84R8](https://forum.dynamobim.com/u/jmayesP84R8)\
**Post date:** [September 29, 2021, 1:20pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/1 "2021-09-29T13:20:14Z")

</div>

This seems to be a popular topic, and I’ve checked a couple of the forum posts but haven’t been able to find a solution yet.  
I’ve got two lists (pulled from element parameters). I’m trying to get it to output the common things between the two lists, but everything I’m doing is coming out empty.  
I would also like to eventually get Dynamo to output the index at which the common thing is on list 2.

As you can see from the highlighting, there definitely _are_ commonalities between the two lists, but Dynamo isn’t outputting them. Any ideas?

\*Side note, anyone know why the second List.Sort didn’t actually sort the list?

 ![1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/1/d122b26f85389429da5e30ba4ac4e023fb54a827.png)

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [September 29, 2021, 1:48pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/2 "2021-09-29T13:48:12Z")

</div>

Hi @jmayesP84R8 ,

Have you tried to change the lancing of the “List.Setintersection” to auto?

---

<div class="post-metadata">

**Author:** ![jmayesP84R8](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jmayesp84r8/32/120483_2.png) [@jmayesP84R8](https://forum.dynamobim.com/u/jmayesP84R8)\
**Post date:** [September 29, 2021, 2:02pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/3 "2021-09-29T14:02:42Z")

</div>

Yep! When I do, List.SetIntersection just returns a single “Empty List” output instead of the longest list you see above.

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [September 29, 2021, 4:24pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/4 "2021-09-29T16:24:51Z")

</div>

@jmayesP84R8 I believe there is a Type mismatch happening. Although I have "Comment: " in both the list but one of them is a Parameter and the other is a String, so the intersection is Empty.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/9/4959f28f93fde0654300d8a0e8238c745426a5d8.png)

Put the Object.Type node to verify that’s not the case with you.  
If that’s the case then drop in a String from Object node and give it a try.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/2/32cc08e875fbf3ed9368ab7f19f6234a4b78d91b.png)

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [September 29, 2021, 4:29pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/5 "2021-09-29T16:29:04Z")

</div>

@jmayesP84R8 I don’t know what your workflow is since you didn’t share the entire graph.  
But if you are reading values from a file then those values should be exact.  
“Comments” is not equal to "Comments " because the later has an extra whitespace.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/a/5a1a961fcd16aa8c075dceebe8ed13159b55b97a.png)

If that is the case then you can do something like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/6/966f27c12f9b164650916cecda8010e152bbc0da.png)

---

<div class="post-metadata">

**Author:** ![jmayesP84R8](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jmayesp84r8/32/120483_2.png) [@jmayesP84R8](https://forum.dynamobim.com/u/jmayesP84R8)\
**Post date:** [September 29, 2021, 4:55pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/6 "2021-09-29T16:55:09Z")

</div>

@AmolShah thanks for the suggestion! You’re right, one was a string and the other was a Revit.Element, so the comparisons weren’t reading them well. I used the String from Object node (and the List.Sort worked that time), but the List.SetIntersection is still turning up empty lists.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/5/65f17f85aae8b31b803debb3ec97ff91818ffa4a.png)

For context, I’m grabbing some shared parameters from an Excel file (600+ parameters) and comparing them to parameters in a schedule and trying to just sort out the ones we need for particular families (“only” 126 of them). I’m hoping to be able to get the indexes of the 600+ parameters that are common between the two lists and filter out the ones I don’t need.

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [September 29, 2021, 4:57pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/7 "2021-09-29T16:57:36Z")

</div>

@jmayesP84R8 Can you change the lacing from Longest to Auto and see if it works?  
If not, try looking at the Whitespace suggestion since you said Excel is involved.

---

<div class="post-metadata">

**Author:** ![jmayesP84R8](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jmayesp84r8/32/120483_2.png) [@jmayesP84R8](https://forum.dynamobim.com/u/jmayesP84R8)\
**Post date:** [September 29, 2021, 5:04pm UTC](https://forum.dynamobim.com/t/comparing-lists-return-common/68696/8 "2021-09-29T17:04:01Z")

</div>

Pretty sure Lacing will be the bane of my existence.  
Auto lacing worked!

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/6/9630a4ed066ebea5c601b6dabb68fe834fe9679a.png)
