List sorting

I woud love to order a list where 15 is < 142 and not viceversa. They are viewsname, after ordering them I can place them properly. What node should i pick to transform this order into the desired one. bandicam 2016-01-29 17-27-44-993

Hello,

Do a search on the forum for “String.PadLeft” for some examples on how to sort strings “numerically”.

Stellar idea, Vikram! If we use “String.ToNumber” in a composed function, we can sort the list without modifying the original strings:

1 Like

Just responded to a question here with a similar solution…

Used List.SortByKey though

Thanks. 2 solutions are better than one. I used the string to number than after sorting it, adding again the “P” I actually tried both but I could not applied properly Venkov one - here - it results that 43P is before 11P and the warns is Asked to convert non-convertible types"

Next thread is next question.

I am trying to get the elements (perspective views) ordered as the names are, so I can set them properly, but probably I am mixing things up somewhere…

Anyway it seems the compose function fails.

This time the warning is different:

Warning: One or more of the input types are not matching. Couldn’t find a version of __Compose that takes arguments of type (__array)

Note that Dimitar had left the str input port un-wired for both nodes connected to Function.Compose (String.Replace and String.ToNumber)

thanks. I do not know previously I had tried unplugged but it did not work, probably others mistakes were there. This time worked smoothly.

Now I am addressing in how to call the view with this new order…here details on renaming views thread, how node should I pick this time. I tried item.by index but it did not work…

I am struggling a bit with sorting… I have list of elements lets say rooms, I use Element.GetParametrerValueByName and using area to extract this data. I can now sort area list but how I can sort my original elements list with area sorting? I want to use numbering at each level from 1…end…1 sorted by area so No1 will have biggest number

File: RoomNumberByArea.dyn

20160216-3

 

Hi @Vikram_Subbaiah, I’m struggling with the same type of sorting buy for the surface area of an exploded solid. Meaning: I want to sort the list of surfaces by its areas from the small to big.

Thanks in advance!

@Jorge_Villarroel Hope this helps

2 Likes

Thanks! This is what I was looking for. Regards

1 Like