Alphabetical sorting - loop

Hi, I am trying to create a way to sort strings alphabetically. I came up with something that works for the first letter only. Is there a way to loop this precedure in order to take the other letters into account? This exercise if actually more of a pretext as I’m trying to learn how to make looping functions. Thanks for your time.

I am not a coder but I am guessing you would need to use forloop. Quick search and I found this website. It might help.


I know you are trying to learn but I think the OOTB sort node does what you are looking for.

Thank you Steven I appreciate it

I will recommend using python node, there is a lot of help on the web for python, there is almost nothing for designscript.

Hi mostafa,

I also agree python is the best way to solve this. Stay tune will post solution in about 7 hours from now.

Can’t wait! :slight_smile:

Hi Mostafa,

I believe this is possibly the most convoluted example you could have chosen for something as straightforward as looping :smiley:

It’s true that DesignScript is not as user friendly as python but for many cases it’s just as powerful. Here’s a detailed breakdown of one possible solution to the problem:

And if you want to stick with DesignScript to sort the characters, here’s how (Dimitar’s solution doesn’t appear to sort the characters):

1 Like

I thought the idea was to sort the list of strings and not the characters inside the strings?

1 Like

Thanks a lot for taking the time to help me figure this one out.


The exercise seems indeed pointless because there is already a function for that. But it could get trickier if, for exembple, we tried to sort following something that is not as standard as the alphabet.

I will explore the imperative blocks .


Thanks again!


Good evening

Today I am stuck in this excercie because I have to sort this list of wall alphabetically
The dynamo list.sort does not and I’m learning python and I’d like to get your help

thank you in advance.

Hi @amiche_fares ,
you can do this like this:

1 Like

thank you very much ,
Would you know how to do the same with python?
Thank you for your answer