# How to sort points within different branches in a tree?

**URL:** <https://discourse.mcneel.com/t/how-to-sort-points-within-different-branches-in-a-tree/150336>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [November 9, 2022, 10:18am UTC](https://discourse.mcneel.com/t/how-to-sort-points-within-different-branches-in-a-tree/150336 "2022-11-09T10:18:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Joseph\_Oster](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/joseph_oster/32/549124_2.png) [@Joseph\_Oster](https://discourse.mcneel.com/u/Joseph_Oster)\
**Post date:** [November 9, 2022, 12:04pm UTC](https://discourse.mcneel.com/t/how-to-sort-points-within-different-branches-in-a-tree/150336/4 "2022-11-09T12:04:13Z")

</div>

Each branch has a single Y value so you can sort the Tree Statistics ‘P’ _(Path)_ output by that Y value, then construct a new tree using Tree Branch, as I did just ten hours ago here:

> [@Closed Curve Offset Direction Problem](https://discourse.mcneel.com/t/closed-curve-offset-direction-problem/150311/2):
>
> This got to be INSANE!!! First, I tried many different schemes using Flip Curve before giving up and trying the method you suggested: That worked for me in five of the eight cases so… I decided to copy one set of surfaces to all eight positions, which involved some tricky sorting of points and tree branching. The first set of surfaces on the left are copied to all eight positions (white group) and the offset curves at the bottom (green group) then worked fine. man_facepalming

If you had posted your points I would use them to show you, With only a screen shot, advice is the best I can do. Here is the relevant portion of that code:

 ![sort_branches_2022_Nov9a](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/b/d/2bd9ede354e9e459663f6598876f00f3d7ad1212.png)

---

_[View the full topic](https://discourse.mcneel.com/t/how-to-sort-points-within-different-branches-in-a-tree/150336)._
