Sorting each nested list by second value (coordinates)

I’m trying out a weaving script (solely in a Python Script node) but something went wrong with my point order. I have a nested list with several lists sorted by the x-value (see picture). But the y-values should be also sorted in ascending order. I have tried using normal list sorting but nothing really changes. If possible I’d prefer to just change it here in the nested list than going back and trying to figure out where the problem coming from.

Any help is appreciated :slight_smile:

Can you show the full python script? It should be easy to sort in the nested list, just need to get all of the y values and sort them. This post shows a good example of sorting a list based on a different list in python:

The python script is very long and currently not organised at all so I don’t really know what to screenshot of it. I was hoping there is a simple way to sort within nested lists.
Thanks, I will have a look at the link

It is very simple to do so, you just need to get a list of Y values, zip them together and then sort. But yours has a lot of nested lists so I can’t give you specific help without seeing the full output/at least some of the script.

Hello,
you can use sorted() with the Key Functions

list_sort_by_YCoord = sorted(lst_pts_unsorted, key=lambda x : x.Y)
2 Likes

Get the Y values and Sort By Key with list levels.