List.IndexOf not giving me the correct indices

So, I have this situation. I want to get the indices of the first list depending on the elements of the second list.


I don’t understand why I’m getting -1 as indices. The only one correct index is the number 2 at index 4.
Can somebody explain that and how to get the correct indices, please?

My guess is that it is a rounding issue. Try converting to a string first. It also may be that using a dictionary would be better suited for what you are after.

1 Like

Thanks for the reply Jacob.
Based on what you suggest, I created a list manually and it worked just fine. Then, I tried Number.ToString from Springs nodes but it didn’t work (see image). Do you know what node I can use to achieve that?

Try the Orchid package once it will might give the desired results for this scenario…

I sorted it out.
After I converted to string I converted back to number and it worked.


So, I think Jacob was right. Converting to string and then back to number corrected the rounding issue.

Thanks for your help, guys

1 Like