# Dividing branches based on pattern or same values in branch

**URL:** <https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [January 25, 2024, 10:45pm UTC](https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185 "2024-01-25T22:45:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bo\_Ris](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bo_ris/32/540108_2.png) [@Bo\_Ris](https://discourse.mcneel.com/u/Bo_Ris)\
**Post date:** [January 25, 2024, 10:45pm UTC](https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185/1 "2024-01-25T22:45:24Z")

</div>

hello all.  
I am trying to sort elements based on y coordinate from a list that was previously sorted by x. In the picture below is just the basic sketch if something like this is even possible: I want to seek for same values in each branch alone and then divide this branch into new branches containing same values.  
I hope you get my question 🙃

 ![divide branches](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/c/c/9ccbb4dd9814d6362f57f5e4b04a235123f6a567.png)

---

<div class="post-metadata">

**Author:** ![kev.r](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kev.r/32/766021_2.png) [@kev.r](https://discourse.mcneel.com/u/kev.r)\
**Post date:** [January 25, 2024, 11:42pm UTC](https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185/2 "2024-01-25T23:42:49Z")

</div>

Something like this:

 ![unsorted](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/1/f/11fbe364e8307e78e3f59053c0fd19468d1c53a2.jpeg)

Same thing but sorted:

 ![sorted](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/8/c/a8c2c87b9dc6facc1c26f6fa82a312d32acb5118.jpeg)

If you have further questions, post a grasshopper file with internalised data.

Please follow the link and read this entire post:

> [@Help Us Help You](https://discourse.mcneel.com/t/help-us-help-you/50034/1):
>
> Asking questions and getting answers is what this forum is all about. Although people are generally very helpful, there are things you can do to improve your chances of getting good and quick answers. Below you will find some suggestions, but don’t think of them as rules and especially don’t think of them as guarantees. 1. Choose a descriptive title for your post Don’t title your question Help! or I have a problem or Deadline tonight!, but actually describe the problem you are having. 2. Be s…

-Kevin

---

<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:** [January 26, 2024, 12:04am UTC](https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185/3 "2024-01-26T00:04:31Z")

</div>

oh wow, ok, the Unflatten here is just awesome 👏 👏

---

<div class="post-metadata">

**Author:** ![Bo\_Ris](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bo_ris/32/540108_2.png) [@Bo\_Ris](https://discourse.mcneel.com/u/Bo_Ris)\
**Post date:** [January 26, 2024, 9:10am UTC](https://discourse.mcneel.com/t/dividing-branches-based-on-pattern-or-same-values-in-branch/174185/4 "2024-01-26T09:10:24Z")

</div>

Thank you for this. I realized that I started solving my problem in a totally wrong way but this gave me some ideas.  
List item was a perfect solution, I was trying to replace paths 🤦 I was trying to sort boxes based on center and couldn’t reference corect box according to the last list. Puting Sort before Create set did the trick.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/f/d/5fddaa02fd9f687bf9decb7cf737806708972464.png)
