I have a list of objects of the same type
lis = [<obj>, <obj>, <obj>]
that I wish to sort naturally by the object attribute name
. I have tried
sortedlist = sorted(lis, key=lambda x: x.name)
However this sorts the list as
A1
A10
A2
Not in the format that I wanted
A1
A2
A10
I have tried modifying the code from sorting alphanumeric strings, but I can't get it working for a list of objects.