Sorting nested Lists

I have some nested lists of surfaces. What I want to do is to sort each of these nested lists by their area. I tried to use the SortByKey node, and it is just returning nulls. I feel like I’m missing something small that should make this work.

You can try either of these two methods. I would recommend using the SortByFunction node instead if you’re in 0.9.0 and later. When using a node as a function you will have to leave the input open as it “maps” the function on the list you feed the sorting node. Additionally you have a nested list and it requires the use of the List.Map node to operate one level down in your list. OR you can use replication guides as the below example illustrates. The notation indicates that the function will operate on the second level of your list.

1 Like

Organon, that was what I thought would be the solution, but for some reason I don’t have the option of lacing for sort by Key. Also, Jostein, does that method work for sorting the surfaces by their area? It seems like it’s only sorting the areas.

Use SortByFunction

I can’t quite get what you mean? The output from the List.Map node or the Codeblocks are the sorted surfaces, but I added a Surface.Area node to “prove” that it worked. :slight_smile:

Jostein,

My question is not exactly about this thread, but it can be related to your suggestion. I would like to have your advice if you don’t mind.

I am trying to panelize surface per color range and apply the different types of panel onto each color. Your suggestion seems to have lots of potential since as the first step I want to sort surfaces out per the hue of color mapped through image. But I cannot figure out the next step to filter surfaces within the certain range in order to receive the certain type of panel without changing the location. It seems like if I just sort surface by color range, it will re-lay out surface.

Can you share your insight please? I attached dyn and image file for your reference.

Thank you for your time and interest in advance!

Panel Test

Addressing the original post…

2 Likes

Jostein, I see now, Thanks for the help!

This worked!!! and I dont understand why the short lacing wouldn’t work…anyone?