List.Insert

Hi everyone,
I have trouble with lists order. As visible in the attachment I created 2 lists, the second one is divided in sublists with some of the same members of the first one.
I found the correspondent index of each sublist of list 2 in list 1 and then used the node List.insert (I’m not an expert so I looked for AddItemto front at index nut it doesn’t exist ah ah ah ).
I tried working on levels and lacing but still the resulting list is not the sum of the 2 as expected.
Some one has had similar probs? Or maybe could some one tell me where the mistake could be please?

(Of course this is just an example of the issue I have with the job, it’s way larger in amount but the criticity is in here)

Thx in advance to all who would help.

Hi @e.cietto
What you want to with these two lists is a bit unclear.
Try to share any example of the result you are expecting.


I expect as shown

I think you want to insert the child list of under list that have the same iteam to child list of above list.
You can try this solution


test1.dyn (5.7 KB)

import clr


clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

list1 = IN[0]
list2 = IN[1]
listout = []
for i in list1:
    for j in list2:
        if i[0]==j[0]:
            for ji in j:
                i.append(ji)
        else:
            i = i
    listout.append(i)

OUT = listout

i was to late the python solution @thanhdatp297GRTHP posted might work better but here is my solution.

1 Like

Hola amigo @e.cietto buenas. I always get lost when there are 3 imputs and they involve levels, but here’s an alternative, I hope this helps.

Exactly what I was looking for thx a lot.
And Thank you all for your help