Sort tree branches according to distance

Hi all,
I need to rearrange both trees (violet) according to the -minimum- distance between item 0 (red) in both trees, which are points.
I’ve tried sort listm didn’t work and sort tree doesn’t seem to work. Any ideas?
Thanks and stay safe.

It is extremely hard to understand what you want to do.
Why don’t you provide your .gh file and organize what you are trying to do in step by step?

Any way, it seems that you want to match GIS sort of data to the building footprints.
“Data” circled with purple has point, data, level and sort of building’s information.
Second circled merged data has “FootPrint” and Centroid.
You want to match these two. Right?

One way to match this problem would be knowing the item index (Tree index in this case? I don’t know exact terminology for this) of the “point” that is matching with “FootPrint” and “Data”
It can be problematic if the number of “Data” and “FootPrint” does’t match and makes empty or null list.

By the way, you don’t have to store every data into list and list of trees in “FootPrint” since this is making problem more complex.
Leave this list in “list” condition.
Next, just retrieve the point from “Data” maintaining its structure and flatten it or something.
Than try to get the matching index of this points.
This process can vary depending on the situation but you can use sort, distance or anything but I cannot judge at this point.

Now since you know the “index” of closest matching points, you can also use this to sort the nested list in the “Data”
Call the exact list in “Data”'s tree using Tree branch.
That’s it!

PS. I just noticed that you might want to sort the “FootPrint” to “Data”. It would be better to clear this out in the question too.


Here, (340.7 KB)

Hi, have you figured out?
I have tried to fully solve your problem but couldn’t figure it out smoothly since some data doesn’t make sense to me.
I just tried my best to help you understand the concept of matching data.
Please read what I have wrote above and find duplicating or missing data. (344.1 KB)