# Repeat function for each item in list

**URL:** <https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172>\
**Category:** FAQ\
**Tags:** revit, python, dynamo\
**Created:** [September 14, 2021, 8:40am UTC](https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172 "2021-09-14T08:40:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![1074050](https://avatars.discourse-cdn.com/v4/letter/1/a3d4f5/32.png) [@1074050](https://forum.dynamobim.com/u/1074050)\
**Post date:** [September 14, 2021, 8:40am UTC](https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172/1 "2021-09-14T08:40:25Z")

</div>

Hi

To keep it short, I need some help.  
Is there any way for me to repeat the “Classification” for each item in the list (All Elements of Category)?

I have tried multiple solutions but can’t seem to get it to work.

Thanks in advance.

 ![help](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/c/1c0d99e77d27a249068bc131480432a5ab58a3ac.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:** [September 14, 2021, 9:24am UTC](https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172/2 "2021-09-14T09:24:10Z")

</div>

Use a List.GroupByKey and a List.SortByKey instead, both of which at list Level 2 (@L2). This will require you don’t pass any functions though, so you will need to wire in the input to the FamilyType.Name node as well.

---

<div class="post-metadata">

**Author:** ![1074050](https://avatars.discourse-cdn.com/v4/letter/1/a3d4f5/32.png) [@1074050](https://forum.dynamobim.com/u/1074050)\
**Post date:** [September 14, 2021, 9:33am UTC](https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172/3 "2021-09-14T09:33:01Z")

</div>

That dosn’t solve my problem unfortunately.  
It can’t work if the “Sort by function” has a list input with mulitple element types.  
For the rest of the “Classification” proces to work it needs to be only one element list at a time.

---

<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:** [September 14, 2021, 10:21am UTC](https://forum.dynamobim.com/t/repeat-function-for-each-item-in-list/68172/4 "2021-09-14T10:21:26Z")

</div>

The failure is from having a list of lists.

What happens if you replace the sort by function and group by function to sort by key and group by key as I indicated? Be sure to wire data into the FamilyType.Name node, set all inputs to be @L2, and use and the ‘sorted keys’ become the keys for your group by key node.
