Sorting elements/points

Hi there guys. I got a pair of questions about the functioning of the script you see in this image:


1- If putting Point.X node in func input is sorting from less X to max X. How would be sorting from max X to less X?
2- Why when I sort the points with Point.Y (being all values the same) node the X axis get unsorted? As they are all the same, shouldn´t it just remain as it is? Ok assuming this works this way for some reason, how would I sort the elements in two dimensions (let´s say from the top left, to the bottom right).

Thanks!

what about this ?

1 Like

So cleand and so good, thanks! In case that someone come to this, I just want to point out that in my case, I have had to mark “use the same list structure” and “use levels” in the List.Reverse node. Cause if you dont do that and you have list structure defined, this node will reverse that to.

Thanks again! This forum is gold.

1 Like

Just noticed that this script doesn´t sort the points! It creates new points… that yes, are sorted like I want them to be, but it creates new points! Sorry I didn´t noticed this at first.

Not new points, but a new structure of the points you already have. If you are concerned with the display, just turn off geometry preview for all the extra nodes.

This is how Dynamo and visual programming in general work.

Think of it as writing down a weeks worth of groceries in a list. When you’re done you might make a second list where items were grouped by aisle to keep you from having to run from one end of the store to the other between each item. You then made a second list where items were sorted by their distance along the aisle, so that you didn’t have to run up and down the aisles repeatedly. In the end you’re still buying all the items on your original list, and unless you made an impulse buy nothing else was added beyond what was in the original list. Fortunately Dynamo and computers are devoid of emotion so they don’t add that really good looking steak into the cart, even if it’s on sale and would be awesome for a BBQ on Saturday.

To understand this better you can solve a quick toy problem in a Revit environment. Place five point based family instances (the desk that starts as the first component in the Architectural template works fine) in a Revit model. Then in Dynamo, select the families, get their location, and use the values of those points to sort and group the desks instead of the points. You will see that there are no new element ids in your list, and if you go back to Revit there are still the same number of desks in the model as you originally drew.

1 Like

You are absolutely right. I still need one more level of abstraction to understand this but Im on the way of it. I did the problem you propose and I understand what I do. Its just that sometimes I cheat myself in the understanding of this logic.

1 Like

In case its useful for someone. Iknow this is pretty much the opposite to the optimal or logic solution but I will show how I finally solved the original problem.


I know that this is “shitty code” but still work. I had a problem sorting points at the same P.Y (I couldnt use List.IndexOf cause it had repeated indexes) so I had to add an “A”…“Z” tag to every item to keep the sorting logic working. As I also used List.Reverse node, then it has to b “Z”…“A”, instead of “A”…“Z”.

Regards.