Sort Dynamo points by coordinates


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

import clr
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)


@Khasan_Mamaev This should work too…

Using Design Script…


Ooh, fine


And if it’s not Dynamo points, but nested lists



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