Sorting two lists

Hello I have two columns on my Excel sheet.
One column is the list of food type (snack, meat and fruit)
and the other column is the list of people’s name who ate the food type.

I’m in the middle of creating the script where it intakes the csv file and spits out a clean list of ‘who ate which food’ so for example.

Fruit = amy, Tim, Kevin, Lily, Toby // Meat = Charles, Kren, Brian // Snack = Brian, Tim, Toby, Amy

This is the script that I have so far and I am bit confused of how to have one unique item for each food type and connect the list of people who ate them.

Please let me know if you have further question!


Hi @mrkpkimEMSRM

Is this what you need?

1 Like


@Kulkul yes thats exactly what I’m looking for!

However what is the python script? is that something that I could replicate with regular nodes?

@mrkpkimEMSRM Here is the snippet:

ColumnA = IN[0]
ColumnB = IN[1]
OUT = {key:[ColumnB[i] for i in range(len(set(ColumnB))) if ColumnA[i]==key] for key in set(ColumnA)}
1 Like

If you’re a beginner in this then you could use @sovitek method.

1 Like

thank you for the response - I think @sovitek 's method definitely works but only when you hard code or assign people’s name in Dynamo. The people’s name list is coming from Excel sheet for me which im not sure how to integrate into his suggestion.

Generic node method, you would need to clean up the list on the right side based on what your goal is.


Thank you very much!