Help with group items in lists

I need to gather number items from two list (A1 A2 A3…) and (B1 B2 B3…), they are same length and they are naturally grouped as A1-B1, A2-B2…Ai-Bi

Now I need to group further: if Bi is found in ListA, like Bi=Aj, then I need to group (Ai, Bi, Aj, Bj). Then I need to cycle this operation until Bx is not found in List A or already match grouped items.

Following are two examples:

ListA=[0 2 3 4] ListB=[2 1 5 3]; What I need is ([0 2 1][3 5 4])

ListA=[0 1 2 3 4 5 6 7] ListB=[3 0 1 2 7 4 5 6]; What I need is ([0 3 2 1][4 7 6 5])

Can use either Dynamo nodes or PythonScript.


Hi Koz,

Can you post screenshot of your workflow here.

I am trying to join all joinable curves into polycuves. Now I have filtered out the single curves and have the index number of the curves which are joinable. But only two curves in list. Next step is to group them to get all curves can be joined into single polycuve. And that is what I am seeking for help. Following is the existing

screen short

I managed to get this done by a lot “for…in” in python.

The function works and I have uploaded it to package as Curve.SuperJoin, feel free to install.

<br class=“Apple-interchange-newline” />