Elusive issue with grouping by key

I am making script that adds a number to elements in schedule (“Mark” value). It is working but with few issues that I can’t seam to resolve.

I have schedule and I want the elements to be sorted by Family and type>Lenght and when all of the elements with “Lenght” parameter are sorted then sort by Family and type > L as seen here:


.
.
.

Unfortunatelly issue 1:
A lot of the times it’s not sorting by Length/L even if it’s sorting by Family and Type.

.
.
.
Issue 2: After running the marking script I always end up with weird mark at the end


.
.
.

Here’s the script:

I can’t sort elements with a schedule template otherwise I can’t add “mark” parameter properly. I need to sort items by familyType>L/Length in dynamo to properly add “Mark” to them.

I believe the issue arises in sortByKey step I just have no idea how to fix it or what exactly is wrong.

@1bitBoolean ,

did you check also your schedule settings ?
2023-06-13_13h52_49
KR
Andreas

Schedule template is sorting only by “Mark”

If I set it to also sort by Lenght it won’t change anything since that would require to rearrange 1,2,3,4,5… to 1,4,3,5,2… or something since marks are assigned in dynamo from the elements that are grouped by key.

Curious as to why you have two groups in your graph that are assigning mark numbers. Best way to approach is blank out all the mark numbers. Set up your schedule with filters and sorting methods to get the data in the order that you want. Mimic those exact filtering and sorting/grouping steps with Dynamo and then have one group that assigns the mark numbers in order to all the elements in your final list.

Yeah, but seams my current graph doesn’t sort properly. If I can get it to sort properly I can use template. Need help to properly sort in sorting phase.

Also I got 2 graphs because I mark all elements with “Lenght” parameter and then grab the last index it used and then take all elements with L parameter and continue giving marks starting from index it stopped with Lenght containing elements

You need to sort and group by one parameter and then sort by subgroup for the next parameter. If you just sort and sort without grouping then you undo everything you’ve done previously. There are plenty of similar topics on grouping by multiple parameters that should offer you some help. The only difference here is that you have blanks for one of those parameters.

2 Likes

Assuming that you don’t have a case where an item has both a length value and L value. Group all items by family type. Filter that list for every item that has a length value. Use the list by boolean mask method. Sort the In output list by the length value and give mark numbers. Sort the Out output list by the L value and give those the next sequence of numbers.