Hi. I do want to sort a list of numbers in alphabetical order, means 0,1 … 9, 10,11 … 19,20, … 99, 100, etc, bet instead I do have a list like 1,10,11,etc.
How can I do this kind of sorting?
Sort_Numbers.gh (7.9 KB)
Hi. I do want to sort a list of numbers in alphabetical order, means 0,1 … 9, 10,11 … 19,20, … 99, 100, etc, bet instead I do have a list like 1,10,11,etc.
How can I do this kind of sorting?
You have a tree, not a list.
Flatten the tree and use Sort List
for numerical order or Sort Text
for alphabetical order - it seems you want the first one with your example.
Sort_Numbers.gh (11.8 KB)
And how I can sort the original data from the Data
input? If I do pass that information into the Sort List
component I do get an error. My definition was just an attempt to sort the input data.
Unfortunately don’t works with more complicated data.
Sort_Numbers_more.gh (14.0 KB)
Thank you for this solution. I do figured also by myself using your first definition but using a quite ugly List Item
and Concatenate
to decompose and recompose the initial data which resulted into a quite big cluster.
Hi, is it possible to apply this to data that has letters in it also? I was struggling to apply the above to what Im trying to do. Essentially my end goal is for the list to have the below list read in the correct order.
Thanks Dale! That works well. I have another similar one with similar applications but I need to maintain the properties of the Views to be able to place on a sheet but in the natural order? is this possible?
@Hayden_Payne You need the index It would be easier to obtain it within the code but I am still with R7 and can’t acces to the new Script Editor @dale.
Anyway you could find it externally with FindSimilarMember component.
Nice. It is possible to add an additional input-output to sort also the geometry IDs correspondingly? I am interested on sorting some geometry IDs by the names of the geometry. Best regards.
Thank you @dale For learning purposes, is there any possibility to translate your python to C# using the same logic?
@Cumberland try this.
@dale could you please tweak it so that you can sort other list in parallel?
Fixed (hopefully) here: Sort a number list which contains text - Grasshopper - McNeel Forum.
For me at least, up to now works as expected.
meanwhile you can use Member Index + List Item for that
i think it could mess things if i had two identical values to sort and member indices could be somehow mixed up