# Sort list based on sheet number with element ID

**URL:** <https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497>\
**Category:** Lists-Logic\
**Created:** [November 15, 2018, 1:03pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497 "2018-11-15T13:03:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 15, 2018, 1:03pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/1 "2018-11-15T13:03:49Z")

</div>

Hey!  
Im trying to make a list of sheets which are in an assembly. This list should be filtered based on sheet number instead of element ID. The list in red is the list that needs to be sorted. The blue lists shows some ‘trial and errors’ , all without element id. Without element ID the output is not useful for the rest of my script.  
I’m pretty sure it should be quit easy to fix, but I’m not sure how…

I hope someone can help me out!

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/1/112162811d34691abc4bf95acbd9ed660d214ccd.jpeg)

---

<div class="post-metadata">

**Author:** ![Jan\_Secnik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jan_secnik/32/55692_2.png) [@Jan\_Secnik](https://forum.dynamobim.com/u/Jan_Secnik)\
**Post date:** [November 15, 2018, 1:15pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/2 "2018-11-15T13:15:19Z")

</div>

Hi just send the data from Sheet.SheetNUmber (or something else) to List.SortByKey - Keys.

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 15, 2018, 1:19pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/3 "2018-11-15T13:19:20Z")

</div>

Thanks for your suggestion! However, i already tried to do that, but then the next input will be a string and not a sheet. The rest of my script doesn’t work with strings, only sheets 🤔

---

<div class="post-metadata">

**Author:** ![Jan\_Secnik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jan_secnik/32/55692_2.png) [@Jan\_Secnik](https://forum.dynamobim.com/u/Jan_Secnik)\
**Post date:** [November 15, 2018, 1:24pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/4 "2018-11-15T13:24:45Z")

</div>

Yes thats why you use Sheets (elements) in List input and Sheet.Numbers as keys 😉  
Sorted List outputs Sheets, Sorted Keys outputs sorted Sheet.Numbers.

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 15, 2018, 1:36pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/5 "2018-11-15T13:36:30Z")

</div>

Yess, but because I already filtered out all the sheets who are not in an assembly, the list with sheet numbers is longer than the list which needs to be sorted. I also tried to use this Sort by Key node before filtering out the other sheets, but that didn’t work either. Any other suggestions? 😁

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3ff15d26a02ea3d31357e1544c77be31e73ceaaf.jpeg)

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [November 15, 2018, 1:44pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/6 "2018-11-15T13:44:36Z")

</div>

I don’t think you got how the Element.GetParameterValueByName and List.SortByKey work 😛

Plug your sheets to this node, and then this node to List.SortByKey :

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/98148abf86e33f46fe42fce71b6ab5012d543a04.png)

---

<div class="post-metadata">

**Author:** ![Noes](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Noes](https://forum.dynamobim.com/u/Noes)\
**Post date:** [November 15, 2018, 1:51pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/7 "2018-11-15T13:51:43Z")

</div>

Should’ve known that… Works now, thanks! 😃

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [November 15, 2018, 1:52pm UTC](https://forum.dynamobim.com/t/sort-list-based-on-sheet-number-with-element-id/28497/8 "2018-11-15T13:52:55Z")

</div>

Glad your figured it out !

I switched the solution to @Jan_Secnik’s post as he first described this solution 😉
