Sort Dynamo points by coordinates

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