Thank you.
But now the list no longer consists of objects but only of the names.
I would like to access the objects in this list for example like this:
I haven’t done much with python in blender, but I would assume that the solution would be the same as a normal python so this is what I would do.
Define a function to return the name of the object.
def getobjname(obj):
return obj.name
and then use that function as the key to sort your list:
sorted(mylist, key = getobjname)
Edit:
I remembered the Lambda way to do this:
sorted(mylist, key = lambda obj: obj.name)
look up lambda functions, as they are cool and I may have made a typo. The short explanation of Lambdas is that they are anonymous functions, before the : is the function argument, and after the : is what the function returns. In this case the Lambda take in the obj and returns the obj.name, sorted() then uses what is returned to sort the list of original objects.