Sort Dynamo points by coordinates

http://image.prntscr.com/image/1d3ebd863adf490382ab2c2c5a008929.png

1 Like
reset = IN[0]
if IN[1] != True: off = 1/0

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

from operator import itemgetter

pts0 = IN[2]

pts = map(lambda p: [p.X, p.Y, p.Z, p], pts0)

sortpts = sorted(pts, key = itemgetter(0,1,2))

OUT = map(lambda x: x[3], sortpts)
2 Likes

@Khasan_Mamaev This should work too…

Using Design Script…

5 Likes

Ooh, fine

And if it’s not Dynamo points, but nested lists
http://image.prntscr.com/image/6c2a7674c6204c0e92c35fbad05ee2b6.png

http://image.prntscr.com/image/28f6f018b6814e169ece08a19afa99ac.png

1 Like

But be aware that the Python script works much faster than the Dynamo script. This becomes clear when the elements are sorted by more than a thousand