Sorting a tree by the first element in a branch

Sorting a tree by the first element in a branch. How to do this?

Can you show what you want the outcome to be? Not quite sure which items & how you want them sorted.

Also, upload code.


SORT.gh (3.3 KB)

I can’t figure out the logic behind your list sorting - it looks random.

this was supposed to sorts branches depending on the alphabetic order of the first item of each branch

“_” comes before “c” but I don’t really get why “p” comes before “m”

SORT_inno.gh (13.4 KB)

it’s weird because it looks like your text is not recognised as proper text? where does it com from?

looks at what happens if I manually type the first letter of your text, compared with the first letter taken directly from your text:

1 Like

Oh, thanks. The letter most likely came from a different keyboard layout. Do you know how to move a fastener item to the end of the list?

the first thing that comes to my mind is to replace the underscores “_” with something like the last letter of the alphabet, just for the sorting purposes

(A) is what the Sort Text component is sorting

SORT_inno_Re.gh (16.2 KB)

but knowing that there are already some weird characters which are not recognized as such (like the “m” that is not seen as an “m”) I don’t know how much reliable this can be…

Thank you very much for your help. That’s what I needed. You led me to the right decision. Now works well with different data. Can you advise how to better understand and learn how to work with data trees?

Practice! Use temporary text panels to examine and understand all component outputs.

1 Like

I think the videos from a post of yesterday are a very very good starting place:

1 Like