Efficient sorting of points based on x,y,z values

Hello, I was wondering if there might be a more efficient means by which I can sort and color these spheres in Python to Grasshopper? At the moment, I have utilized various grouped Grasshopper sphere components with color swatches to differentiate between points created from a Python code component. However, it seems to come at a noticeable performance cost—would it make any computer performance difference to control the coloring in code?

Grid Color Sorting.gh (13.3 KB)

To me, it’s not entirely clear, if this is the intended behavior as it would sort the same point into multiple lists. Also, never do a comparison of number of “==”. This time it might work, as you are using randint, but in the general case, this might fire back.

Assuming you want to sort the points into the 8 octants, this would be my approach.

1 Like

Uploading your script or posting it with the code formatting option instead of pasting a screenshot would keep other users from having look at your screenshots and type what you already typed…

Interesting, I was not aware that loops could be placed within lists. That seems as though it would serve to reduce the redundancy of having multiple lines of for loops in the code.

It was intentional, so you have to type, maybe make a mistake and think about it. @kraigsims2

Grid Color Sorting_V2.gh (23.6 KB)

2 Likes

That makes sense, thank you for your help!

1 Like