# Sort by rotation

**URL:** <https://forum.dynamobim.com/t/sort-by-rotation/49006>\
**Category:** DesignScript\
**Tags:** dynamo\
**Created:** [April 7, 2020, 2:17pm UTC](https://forum.dynamobim.com/t/sort-by-rotation/49006 "2020-04-07T14:17:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![domenico.calabrese](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@domenico.calabrese](https://forum.dynamobim.com/u/domenico.calabrese)\
**Post date:** [April 7, 2020, 2:17pm UTC](https://forum.dynamobim.com/t/sort-by-rotation/49006/1 "2020-04-07T14:17:51Z")

</div>

Hello everyone,

I’m new to the forum and I recently started using Dynamo. I have to group some elements by parameter value, number them and then sort them clockwise/counterclockwise starting from a set point. As you can see I was able to group and number but I have a problem to sort them, I tried to sort by point coordinate but I don’t achieve the desire numbering.

Do you know a way to number starting from a point along a clockwise/counterclockwise path?

Thank you!  
[group and sorting01|690x198](https://forum.dynamobim.com/uploads/short-url/gvc9ecLwM4VMWum8xhR0tTrZ8lR.png)

 ![group and sorting02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/2/52a468718518536c18a05263be5c9a88aa347d33.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [April 7, 2020, 5:13pm UTC](https://forum.dynamobim.com/t/sort-by-rotation/49006/2 "2020-04-07T17:13:21Z")

</div>

Create a vector from the element point to the ‘center point’, and then find the angle of that vector and the ‘starting vector’ (say north for the sake of argument) using the Vector.AngleAboutAxis where the axis is the global Z axis. Then use a List.SortByKey node to sort the elements according to the angle values.

---

<div class="post-metadata">

**Author:** ![domenico.calabrese](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@domenico.calabrese](https://forum.dynamobim.com/u/domenico.calabrese)\
**Post date:** [April 7, 2020, 5:40pm UTC](https://forum.dynamobim.com/t/sort-by-rotation/49006/3 "2020-04-07T17:40:00Z")

</div>

Many thanks @jacob.small, I’m tryng to do a vector between the “centroid” of the single element and the “centroid” of the whole model then I can do as you said sorting by angle between the vectors.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [April 7, 2020, 9:49pm UTC](https://forum.dynamobim.com/t/sort-by-rotation/49006/4 "2020-04-07T21:49:18Z")

</div>

This should set you on your way: [Dynamo Dictionary](https://dictionary.dynamobim.com/#/Geometry/Vector/Create/ByTwoPoints)
