Problem with matching list 1 with List 2 in alphabetical order

Hi,
I am having issue matching 2 lists in alphabetical order.
don’t know where I am making mistake.
here is what i want in the second image.

Match Nested List Issue.dyn (32.0 KB)

@aan

try this:

# 0️⃣ Input list of capital letters
capital_letters = IN[0]

# 1️⃣ Dictionary of combinations
combinations = IN[1]

# 2️⃣ Resultant list
result = []

# 🏓 Iterate over the list of capital letters
for letter in capital_letters:
    # Pair the letter with each key in the dictionary
    for key in combinations.keys():
        result.append([letter, key])

# ✅Output the result
OUT =result

Use the List.SortByKey and List.GroupByKey nodes.
To set up a non-sequential order use a dictionary as an order index lookup
It takes a bit of jiggery pokey with levels and lacing, here it is with OOTB nodes

And with python

sort_dict = dict(zip(IN[0], range(len(IN[0]))))

OUT = sorted(IN[1], key=lambda i:(i[0], sort_dict.get(i[1])))

1 Like

@aan , it would be better to create the directory if the lists are limited.

1 Like


Match Nested List Issue.dyn (36.8 KB)
Here, I tried too.

1 Like

@ Draxl, @Mike, @Vijay and @rajesh, Thanks a lot all for sharing different solutions.

I found reajesh solution perfect because I don’t have to change the main data.
In other solution I have to tweak the main data to get the desired result but all solutions have something to learn which can be used in some other workflows.

Thanks a lot all once again.
Regards,

2 Likes

Just listing a simple workflow here I feel would work.

or a more detailed according to the list provided.

1 Like