Sorting Object.children CListValue

I need to have a list of children objects sorted by objectname.

Is there a method/function I could use?

like


Childs = Object.children
Childs_sorted = Childs.sort()

Yes, there’s a function. This should work.


children = obj.children.sort()

EDIT: If not, try


children = list(obj.children).sort()


children = list(obj.children).sort()

First of all thanks for the quick reply!!!

…maybe I’m unlucky… :frowning:

TypeError: unorderable types: KX_GameObject() < KX_GameObject()

Ah, so that won’t work. You’ll need to sort it by the name of the child. This should work:


children = list(obj.children).sort(key = lambda object: str(object.name) )