List based on new list

I have Light fixture family list and Circuit no. belongs to it. I want the light fixture count based on Circuit number order like R1 - Light Fixture family name - Light fixture count. I tried at some extend with the help of this forum. I got the Circuit number order as R1, Y1, B1, R2, Y2, B2,… But I couldn’t achieve the result. Hope someone have the solution.

You need to make sure your Family Name list goes through the same filtering, sorting, and grouping as your Circuit Number list otherwise the values won’t align in the end. In order for SortByKey to work with your current workflow the number of items in list need to match the number of items in keys.

Yes. I tried it. But I couldn’t achieve the result. It will be very helpful if anyone have the solution.

Try using a dictionary to streamline the initial sorting, and like I said, make sure both lists get the same sorting so they stay aligned with each other.