Sort list by original list

I need help sorting a modified list by the original list. I separated the list, did some suffix and prefix changes, then recombined the list. but I need the final list to be in the same order. any thoughts?

thought it was fixed sorting the list prior to adding brackets using list sort by key. everything is in order except the items that have had the suffix removed.

can i make it not a strict match?

I starting to doubt myself, but AFAIK the order of your List shouldn’t have changed after making the changes. But i don’t know how your script is set up. Need to see your whole script to provide a better answer.

1 Like

that’s because i had to separate the list to alter the particulate items then combine them

hmmmm, maybe i need to rethink how to strip the suffix

What is your output BEFORE you filter?

Got it working by skipping the list sort and just using the bool mask + list creation in other parts of the graph. seems jankity, but if it works why fix it.

There are often multiple ways of doing things in Dynamo. Though some ways may be better than others.

Just other ways you could have done it for example (to prove my point :wink:).

Pretty sure people can come up with more ways.

i like your use of the code block for adding the brackets. i always forget to use them for stuff like that.

adding the modified items to the front of the list still give me issues since the items I separated are in the middle (essentially could come from anywhere in the list). the outcome is still an out of order list.

Yer, Code Blocks are pretty powerful. Just Like Node to Code.

Without seeing your INPUT (read; original List) it is hard to come up with a better / more robust solution, but i think my second option (image) would deal with this :point_down:.

You can likely do the whole thing in a Code Block with a conditional statement. You could even include whatever your condition is, but the example below uses the results (boolean list) as an input. This allows you to handle everything “in line” so the results keep their order.