# Sorting struggles

**URL:** <https://discourse.mcneel.com/t/sorting-struggles/120417>\
**Category:** Grasshopper\
**Tags:** windows, mac\
**Created:** [March 15, 2021, 11:07am UTC](https://discourse.mcneel.com/t/sorting-struggles/120417 "2021-03-15T11:07:46Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [March 15, 2021, 11:43pm UTC](https://discourse.mcneel.com/t/sorting-struggles/120417/8 "2021-03-15T23:43:21Z")

</div>

yes, you are completely right, I think this is a very clean solution, while my previous one was a patch into another patch into another patch…

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/0/a/80aa4ced58e97eb83f3047c5331a504e1b3f879b.png)  
[sorting subbranches\_Re\_Re.gh](https://discourse.mcneel.com/uploads/short-url/ePwvZP85EZCRypnOv5Qfbx7LBmg.gh) (23.6 KB)

basically, it was not completely clear to me how the contour outputs were organized… but after your thoughts + one more minute of attention + some coffee it became clear enough that the Contour output data structure has the very same sorting order of its Shape input, so it’s possible to use tree stat + replace paths to re-create the very same branching structure you have on the Shape input itself (= data-structure of your Breps)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/7/d/a/7da301cae12089121a8fb33ab7f23b95e16988a6.png)

in my first post -which does the job, **the wrong way** - I did not get that the Contour output did retain the same order of the Shape input, so I went in berserker mode and tried to retrieve to which Brep each Contour did belong with AreaCenter+PointInBrep (which is not mechanically wrong, but because the outputs _ **are already correctly sorted** _ for us, it’s just logically wrong 🤣 )

---

_[View the full topic](https://discourse.mcneel.com/t/sorting-struggles/120417)._
