# List Manipulation - Levels & Elements

**URL:** <https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739>\
**Category:** Lists-Logic\
**Tags:** dynamo\
**Created:** [June 28, 2019, 10:47pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739 "2019-06-28T22:47:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhillegas](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jhillegas](https://forum.dynamobim.com/u/jhillegas)\
**Post date:** [June 28, 2019, 10:47pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/1 "2019-06-28T22:47:15Z")

</div>

[Question](https://youtu.be/JPRjmJnYKzw) Script attached. [script.dyn](https://forum.dynamobim.com/uploads/short-url/hHc7TFKOQItDGOik6rVUNHc3RbV.dyn) (129.1 KB)

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [June 29, 2019, 9:39am UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/3 "2019-06-29T09:39:19Z")

</div>

I zeroed in on your problem.

The culprits are the List.SortByKey and List.GroupByKey nodes.

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

They change the order of the walls (take a closer look at the Element IDs).  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/4/641233f7338d047262885c7d8f49ef5c7c4e9b8f.png)

So the solution would be to use the Parameter.ParameterByName for “Phase Created” and “Base Constraint” after the List.GroupByKey node (just like you did for the “Area”).

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/0/00aad69826b80d0741c33283e8432636adabbda2.png)

And that should fix everything.

Hope this help.

Good Luck.

---

<div class="post-metadata">

**Author:** ![jhillegas](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jhillegas](https://forum.dynamobim.com/u/jhillegas)\
**Post date:** [June 29, 2019, 3:16pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/4 "2019-06-29T15:16:20Z")

</div>

That did work, but I now it’s just down to[cleaning up](https://youtu.be/edTAF3VIdfE) some strings within the list. [script.dyn](https://forum.dynamobim.com/uploads/short-url/q1eFrnxdJVGsZBHi6l87SD6NvsE.dyn) (143.9 KB) [revit file too large to upload](https://www.dropbox.com/sh/1zfgnnlhezgm92r/AADb2_-CqIOBVbQZ1qbPyg1wa?dl=0)

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [June 29, 2019, 7:16pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/5 "2019-06-29T19:16:53Z")

</div>

Hey,  
I have updated the script as per your needs.  
I have also cleaned up your graph since it was using redundant nodes.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/4260e295deafb7ff7efdcf88ac03408f5be26a1b.png)  
[Updated Script.dyn](https://forum.dynamobim.com/uploads/short-url/ocDJeumjORoZVMuZ5w7soiyEMFb.dyn) (39.3 KB)

Let me know if you have any other questions.

Good Luck.

---

<div class="post-metadata">

**Author:** ![jhillegas](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jhillegas](https://forum.dynamobim.com/u/jhillegas)\
**Post date:** [June 30, 2019, 3:49pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/6 "2019-06-30T15:49:20Z")

</div>

Wow amazing! I need to better understand that List.Flatten node.

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [June 30, 2019, 6:45pm UTC](https://forum.dynamobim.com/t/list-manipulation-levels-elements/37739/7 "2019-06-30T18:45:44Z")

</div>

Eventually you will master that node for sure!

Don’t forget to mark the solution so others can learn from your post!

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/3/736dacbbc2db75e0f9233bf192f6ff3ba11dcbc1.png)
