# Grouping lists

**URL:** <https://forum.dynamobim.com/t/grouping-lists/36426>\
**Category:** Lists-Logic\
**Created:** [May 26, 2019, 7:59pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426 "2019-05-26T19:59:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Jesus\_Del\_Pino](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Juan\_Jesus\_Del\_Pino](https://forum.dynamobim.com/u/Juan_Jesus_Del_Pino)\
**Post date:** [May 26, 2019, 7:59pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/1 "2019-05-26T19:59:05Z")

</div>

Hi guys, with this node, I group the lists according to the index, I mean, It groups the elements correctly, but it assign the index in the order it takes the values… In this example what I want to do is group the elements with the number 0 in the index 0, ignoring the order they appear. In this case, the index 3 is the one which should have 2 elements.

 ![Grouping%20lists](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/0/204185cd14b1a101fb01ff002400a18a294dc2f8.jpeg)  
 ![Example](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/2/72adb3a18b31675427d0d471894439209477ee3d.jpeg)  
Any ideas??? Thanks!

---

<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:** [May 26, 2019, 10:39pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/2 "2019-05-26T22:39:00Z")

</div>

List.SortByKey after the List.GroupByKey node, using the groups as the lists, and the unique keys as the key.

---

<div class="post-metadata">

**Author:** ![Juan\_Jesus\_Del\_Pino](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Juan\_Jesus\_Del\_Pino](https://forum.dynamobim.com/u/Juan_Jesus_Del_Pino)\
**Post date:** [May 26, 2019, 11:25pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/3 "2019-05-26T23:25:19Z")

</div>

Seems logic but its not working. I have tried with every possibility about lacing but something is wrong.

 ![Example](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/2/72aa687fe73cdc92682312af76828a07eebb4e6c.jpeg)

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [May 26, 2019, 11:34pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/4 "2019-05-26T23:34:05Z")

</div>

@Juan_Jesus_Del_Pino

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

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [May 27, 2019, 7:42am UTC](https://forum.dynamobim.com/t/grouping-lists/36426/5 "2019-05-27T07:42:27Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/d/0d55d7f28806958c3578d7f6615ee7e0651b7680.png)  
i believe thats what you want right

---

<div class="post-metadata">

**Author:** ![Juan\_Jesus\_Del\_Pino](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Juan\_Jesus\_Del\_Pino](https://forum.dynamobim.com/u/Juan_Jesus_Del_Pino)\
**Post date:** [May 27, 2019, 7:25pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/6 "2019-05-27T19:25:44Z")

</div>

THIS was the solution, works like a charms. Now Im gonna take my time to understand this. Thanks 🙂

 ![WIN](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/8/48c7c01eb0de1de3a8549e0c6c8aad2dae1881e9.jpeg)  
You can see its working cause there are two items in the 3 index.

---

<div class="post-metadata">

**Author:** ![Juan\_Jesus\_Del\_Pino](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Juan\_Jesus\_Del\_Pino](https://forum.dynamobim.com/u/Juan_Jesus_Del_Pino)\
**Post date:** [May 27, 2019, 7:27pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/7 "2019-05-27T19:27:40Z")

</div>

Good example of list comprehension! Maybe I havent explained it properly. The solution is salvatoredragotta´s image =)

---

<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:** [May 27, 2019, 9:06pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/8 "2019-05-27T21:06:26Z")

</div>

Not sure if I’m just not seeing something, but both solutions work and return the exact same solution. You just need to set lacing and list levels are set correctly in either circumstance.

Here is an example of both using Dynamo 2.0:

 ![Grouping%20and%20sorting](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/5/d562436b640e8f6c3fc97a1da0a2dcf2eca07c3d.png)

And the same graph formatted for 1.3:

 ![3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/1/b1b41b18f9134d55f079282abed48e5952b06647.png)

---

<div class="post-metadata">

**Author:** ![Juan\_Jesus\_Del\_Pino](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Juan\_Jesus\_Del\_Pino](https://forum.dynamobim.com/u/Juan_Jesus_Del_Pino)\
**Post date:** [May 28, 2019, 4:18pm UTC](https://forum.dynamobim.com/t/grouping-lists/36426/9 "2019-05-28T16:18:41Z")

</div>

Absolutelly right. It was my mistake in lacing. The outputs are just the same:

 ![Prove](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/b/1b5780149f68cbbbfd63385f2a03e81ddb4e0af5.jpeg)  
Thanks!
