# Group by key problem

**URL:** <https://forum.dynamobim.com/t/group-by-key-problem/4775>\
**Category:** Uncategorized\
**Created:** [June 29, 2016, 12:48pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775 "2016-06-29T12:48:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sashka364](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@sashka364](https://forum.dynamobim.com/u/sashka364)\
**Post date:** [June 29, 2016, 12:48pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775/1 "2016-06-29T12:48:37Z")

</div>

Hey! I thought, I’ll get the number in the red circle equal to -1000. What have I done wrong?

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/0/000dc5c7c85db0b06d2b31bf47cd22a93c946662.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [June 29, 2016, 1:02pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775/3 "2016-06-29T13:02:27Z")

</div>

Use _List.SortByKey_ instead of _List.GroupByKey_

In your definition…  
Remove _List.Sort_ before _List.GroupByKey_  
You cannot expect correct results after altering the order of the keys without correspondingly altering the order of the elements.

---

<div class="post-metadata">

**Author:** ![sashka364](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@sashka364](https://forum.dynamobim.com/u/sashka364)\
**Post date:** [November 17, 2016, 2:44pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775/4 "2016-11-17T14:44:23Z")

</div>

Hi again!  
I still got a question.

List.SortByKey sorting the keys in some definite way. I dont know how can I sort the list in the way I want to. (with correspondingly altering the order of the elements.)

---

<div class="post-metadata">

**Author:** ![Alisder\_Brown](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alisder_brown/32/14995_2.png) [@Alisder\_Brown](https://forum.dynamobim.com/u/Alisder_Brown)\
**Post date:** [November 17, 2016, 4:28pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775/5 "2016-11-17T16:28:34Z")

</div>

What task are you carrying out and what is the desired output? Im not sure why you are trying to sort the list?

cheers

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [November 17, 2016, 5:35pm UTC](https://forum.dynamobim.com/t/group-by-key-problem/4775/6 "2016-11-17T17:35:57Z")

</div>

New question = start new thread
