Sort Indices of Sublists

For some reason I can’t quite find the answer I’m looking for on this. Other posts seem to address this, but they do not function for my case. All I need is to process a list of lists to sort by their indices (For n-number of Lists containing n-number of lists, sort by indices of said lists). I’ve tried All Indices Of, List Map and List Transpose, List Slice, Sort, Sort By Index, etc and I get empty lists, nulls, the same list over and over. Is there a really simple way to do this that I’m just totally missing here? I’m trying to work without Packages in Sandbox mode.

Assuming you are sorting lists of points, what are you trying to sort them by? Distance from origins? Z values? X values? Y values? Some combination of all the above?

I’m trying to group points by their list index. I.e. group points that appear in list 0: sub-list 0 with list 1: sub-list 0 and so on. Then do the same for items at index 1 etc.

Try List.Transpose with lacing set to longest.

2 Likes

I did. This does not group the indexes as desired. In the end I’m hoping to arrive at a solution for panelizing a surface by points and grouping them together like the lunchbox node. The goal is to use the sandbox so that it would be more readily translated into Dynamo Studio and then possibly used in Formit. Hopefully that helps to illustrate the path I’m taking here. Any other suggestions?

Do you mean flatten but at a specified depth (aka rank)? So if you have a list of lists of lists for example, get all the lists from a certain index (rank) and flatten them into a new sublist at that index (which one could describe as ‘grouping’ I suppose)? Is that what you mean?

Maybe create a clear and concise diagram to explain as you haven’t defined your problem very clearly.

See the definition I’m working with below. What I was getting at in my previous posts: I’m attempting to group surface points into quads to create panels in Dynamo Sandbox (without packages). I’ve got so far as to get groups of the first two points that make up the panels. The problem is that I need to sort the list of lists by their index. This is what prompted my initial post. I haven’t found a way to organize a list by index. If I could, I was thinking I could then generate a list of four points that I could then create surface patches or what ever else from. Does that make more sense?

Thanks

.2017_0627_Sandbox_Surface_v1.3.dyn (36.6 KB)

Try using Clockwork’s “List.SortListOfLists” node.

Thanks. Though, like I said, I’m trying to work without packages so that there is the ability to translate to Dynamo Studio and Formit.

1 Like

Not quite what I’m trying to do. See my definition I uploaded. I’m trying to arrive at a group of four points to use for creating a panel on a surface. Getting one index of the list is no problem. It’s getting all successive indices as well. Also, the sort by keys does not appear to function for just index marks…only values at that index from what I can tell. I could be wrong. Thanks.

If all you need to do is group points to create quads, and assuming you are creating points on a surface which yields a 2D array, here’s one way of doing it:

1 Like

Beautiful. Thanks Thomas! Do you have any of the material from the course you mentioned in that post that you instructed? I’m hoping to understand a little more of that logic. Cheers!

I guess I still don’t have a way to match indices outside of this application. A solution for this would still be helpful. Any other suggestions?

I’ll message you details of the workshop to keep the thread on topic.

I think the ambition you have is possibly un-achievable as you appear to be asking for a holy grail solution that will work no matter what. Its a bit like asking which opening in a game of chess will always win - quick answer: none!

To give you a more practical example: the solution to group of points in 4’s to be able to create quads is entirely different to one that would be needed to group 3 points. Now imagine in another scenario, you need to group two points, where a direction is needed to determine which points to group. That’s 3 simple examples, all of which have very different solutions. With that in mind, consider the fact that there are unfathomable possibilities that we all encounter with these tools on projects everyday. Hence, to get the most out of Dynamo (or computational design tools in general), you need to identify your end-goal, then find a solution to get there. Once a solution is found, you can of course adapt it for future problems that may be similar. The point is, every problem you encounter will be different. The trick is to think laterally and exercise those problem-solving skills.

Bruce Lee once said a great quote about combat which strangely enough applies absolutely to computational design. Maybe this is the answer you are looking for!

"Be like water making its way through cracks. Do not be assertive, but adjust to the object, and you shall find a way around or through it. If nothing within you stays rigid, outward things will disclose themselves.
Empty your mind, be formless. Shapeless, like water. If you put water into a cup, it becomes the cup. You put water into a bottle and it becomes the bottle. You put it in a teapot, it becomes the teapot. Now, water can flow or it can crash. Be like water"

2 Likes