Sort list by original all keys and add empty list where values are missing

Hi all, could you please help me? I’ve been struggling with this problem for a while now. Here is a picture and values in a script.


sortListByKeysAndAddEmptyList.dyn (24.6 KB)

Python can solve this. But is there solution without python?

listsortbykeysaddemptylistPython-script

@Drbohlav You can do something like this with OOTB nodes:

Or maybe just stick with Python since it’s simpler!

OUT = [IN[2][IN[1].index(x)] if x in IN[1] else [] for x in IN[0]]
2 Likes

Another option: You’re just creating a dictionary with unused keys. Set the values for the known keys and then set the rest equal to your default value.

1 Like


sortListByKeysAndAddEmptyList.dyn (14.1 KB)

1 Like