List sorting conditional


Can anybody help in getting list sorting, I have a list of elements and I want to list them with their name and I want only a set of them to use into my project, but I am not finding a correct way or I am doing something wrong. Any help would be highly appreciated, thanks in advance.

Hi @Rock_Ali ,
this should do what you want :

there are many ways to achieve what you’re after depending on what suits your needs the best. See if any of the below can guide you further:

1 Like

That’s much better :smile:

First of all thanks to both of you, and special one to Oslen for simplicity, but now I have one more trouble while grouping. I have a list of families starting with CP-100/19…,G-858…,MH-1/1…, and PIT-1/1. With the string from object node (for grouping) it is giving other result. Please help once again and thanks in advance.


You can use “Element.Name” node if your looking to group by name:

Finally I able to succeed in a different way (long way I think), may be there is a better way with less nodes, but at the end I able to separate a list of items in a sorted way. If any better way or idea is there, please share, thanks once again.

Did you try with “Element.Name” node?

Hi Kulkul, thanks for your reply, with your solution I am not getting the desired result. In your case, thats working fine, but not in my case (may be becoz there is no space in my family names, i think thats the reason it is not grouping properly, or may be I am wrong), if any better ideas please share.

This should work in your case. What it does is it groups elements that have names which have the same 2 first characters. You can set the amount of characters you’re interested in :

Alternative to @Mostafa_El_Ayoubi 's solution:

Many thanks to both of you (Mostafa and Jostein) for your great support, both ideas are working fine with my case and finally, I able to achieve what I was looking for, thanks once again and have a good day, cheers!!!

Hi Guys,

I need some information regarding the way I created the script. Let me brief you something about my current task. I have a family, which has 765 types (family types) and I want to insert data from excel into the family. There are 12 parameters (type parameter), which have to get updated through this script, but the script is taking so long time more than 15 to 20 hours, which is a bit hard for us to work with in the tight schedule. Now, what I want if anybody can correct me with my script if anything is wrong or suggest me any better idea to reduce the time. One more thing, I ran this script on system, which has 32 gb RAM, i7, and 4 gb dedicated graphic card. Please see the below images, I have pastes in three parts but I hope you can understand, the first two are parts, and third one is complete script. There are no errors with the script, but its taking tooooooooooo long time Please provide suggesstion and thanks in advance.

Hi Ali,

I’m quite late here, just wanted to drop a suggestion for people who’ll be referring to this thread in future, that with advancement of Revit version, the tasks like above are quite quick execute by your existing machine. Revit 2020’s dynamo works really fast!
Also as you knew that you need to only enter “Type” parameter, you could have used “Set Type Parameter” node by Archi-Lab, to avoid extra process.
Hope this helps