Sort list by given pattern

Hi there,

How can I sort a List by a specific pattern like in the image?
value with index 0 from list 1 goes to List 2 and replace value 0
value with index 1 from list 1 goes to List 2 and replace value 1
an so on…


You want List Item ?

No, i want the left list look like the right list. With all its branches and all the items in correct order.

Simple enough with a bit of scripting :slight_smile:

d = dict(enumerate(xs))
a = [d[y] for y in ys]

(Be sure to set both inputs to List Access)


Oops, I guess that works as well :sweat_smile:
Anything involving list/tree matching using indices and I instinctively fall back on writing a one-or two liner script - looks like that wasn’t needed here!

Edit: Actually looking back at the code, it could be simplified to:

a = [xs[y] for y in ys]

at which point replacing it with List Item looks more obvious

List Item!?
Thanks a lot,the solution for that seemed to be so far away altough so close! And thanks as well for the introduction in scripting! :grinning: