Reorder tree branches

Hi,

I’m having some issues extracting specific branches from a data tree and keeping them in the correct order. I’m sure this is a simple solution, but I can’t find the anything that is as variable elsewhere in the forum.

I want want to be able to extract branches from A in the order shown in C. It should be noted that the number path index and number if items specified at c will change (ie. could contain and number of items between 2 and 20, with random path values between {0} and {200}). Because of this variation I can’t use Path Mapper

The tree branch or split tree components extract the correct paths (and their contents) but they reorder them according the numerical value of the path index. I need them to stay in the same order as B so I can use the contained geometry further down the definition

Please note that I’m in Australia, so my replies may be a little delayed.

GH file attached,
thanks for your help in advance.

order problem.gh (314.4 KB)

Does it help?

Kind of…
If it is set to maintain, it keeps the branch index, but reorders them according to ascending numerical path value.

However, if it is set to renumber, it extracts them in the correct order, but then renumbers the branches from 0-3 (as shown below).

The next step would be to renumber the branches to match the initial values (which I have also been unable to work out)

Why do you need to do that? Tree branches will always be sorted by their path.

If you want to control the branch sort order and maintain the original path information, perhaps something like this:

order problem_re.gh (323.6 KB)

-Kevin

It’s a good point.
This solution will work, however, the original branch index is used to cull data further in the overall definition. I think I will be able to make a work around through.
The other reason is that I like to be able to keep track of exactly where things are going in my definitions as this one is a pretty big one involving multiple evolutionary solvers.

thanks for your help

Thanks Kevin,
That helps a lot.
I just wish tree branch and split tree didn’t reorder their outputs

thanks again
pete