I am trying to get a list of points (x,y,z) ordered based in the z value.
As a beginner, I thought I could use two lists (xyz and only z) to create a dictionary, then sort it, then create a new list with the sorted positions x,y,z. Why is it not working and is there another better method to achieve what I am trying to?
As a beginner, I would like to understand what I am doing though, and this lambda expression was a bit too much. I tried to translate it into a function and was not successful. Would you mind helping me with that as well?
Dialing this right back… the simplest way to sort by one part of an XYZ is to use a List.SortByFunction node. Then use the re-ordered list to get the Elements in order
for some reason that didnt work here, but I am really curious to understand whats the mistake I am doing with the function in python. I would be interested in understanding how to translate the lambda into a function, if that makes sense? Just as a way to understand what the lambda is doing… Thanks a lot!
import clr
def sortbyZXY(orglst):
orglst.sort(key = lambda orglst: (orglst.Z, orglst.X, orglst.Y))
return orglst
input = IN[0]
result = []
for i in input:
result.append(sortbyZXY(i))
OUT = result