How to reorder list in a specific way

I am new to Dynamo and have an ambitious little project,at least for me.Me and my colleague don’t create all drawings in Revit.For example we make column and core walls reinforcement in Autocad.Here is what i want to achieve,please stay with me.
Dyn file
First i want to get my plan views and reorder then in the way the building is going to be build -foundation,lvl-1,lvl2 …I’ve done that by using strings(not very elegant i suppose ) ,and now a have a list of strings sorted the way i want,but i cannot get the actual plan views sorted the same way and i am stuck.So my first question is how to sort the plan views according to the sorted list.

The next thing i want to do is to get from the excel file only the sheet names and numbers of the drawings done in Revit.I have an idea,but that’s for later.Can someone give me a hand


Look into List.SortByKey. It lets you sort an input list (your views) based on a list of keys (your strings). By default it will sort your keys alpha-numerically, so you may have to apply a value to your keys if that doesn’t work for you.

Thanks for the quick replay.
I’ve tried it earlier and that’s what happens.

This is my graph and the way a fort my view plans

i am doing something wrong :smiley:

What does the error say? I assume it’s because you have sublists. Try flattening your list of keys.

You were right,after flattening the list the error disappear but my list isn’t organized as i want.Take a look.I assume my whole approach is somehow wrong

It’s because of what I mentioned in my first post. SortByKey sorts your Keys input list AND your list input. You’ll probably have to give your keys a separate value so you can sort them the way you want.

Can you show the original list of Plans and the parameters you’re using to sort them by?

Yeah, of course @Nick_Boyts
Here is it.I first search for DWG -these are my plan views which i use for shop drawings and then rather dull i sort them by level,which i set manually.

Can you get the Associated Level for the View and its elevation? Then you could sort by elevation instead of name.

Edit: You could also use Springs.Dictionary.ByKeysValues to get the plans based on a filtered view list.

Views would be your list of filtered view elements (you’d need another FilterByBoolMask node to get only the matching DWG views) and Strings would be the list of those views’ names. Sorted Strings is your final list of view names in the correct order.

@Nick_Boyts Thanks alot.Your first suggestion did the trick.I actually found that you suggested the same solution in another thread, I just didn’t find it earlier,silly me.I didn’t manage to get working the second suggestion :slight_smile: but i’ll have it in mind for the future
Thanks again and now of to the second part of my little project.

1 Like

Glad you got it figured out. Please mark a solution so other people can use this post for reference.