Sort Viewports

Hello Dynamo Friends :slight_smile:

I have a list of viewports and i want to sort it so that all Legends are at the end of the list.
I can identify the Legends by the view name or by the family type, i can also sort the viewnames and the types.
But i have no idea how i cant sort the viewports themselves. My attempt at list mapping failed.

Any help much appreciated :slight_smile:

You’ll probably want to use SortByKey to sort the Viewports based on the name or type. You might also need to convert the type to a value that you can control for positioning, like a number. You can do this with a nested If statement for each type or create a dictionary.

2 Likes

Hi @gerhard.p …probably something here could help…

1 Like

You can also do it @sovitek’s way of checking for the specific type. In that case you can just separate legends and non-legends with a filter and reorder them since it sounds like you don’t care about the order of the rest of the items.

2 Likes

Oh, i just need a bool mask! :see_no_evil:
This took me hours :smiley:

Edit:

And it also works by Sort.byKey with IDs as Keys