Python sort with key=lambda gets TypeError when trying to call x.lower()
03:50 02 May 2014

I am trying to sort a list of objects in Python 3.4 based on the value of the data attribute of each object. If I use:

db[count].sort(key=lambda a: a.data)

everything works fine. However, I want the sort to be case insensitive so I use

db[count].sort(key=lambda a: a.data.lower)

but then I get:

db[count].sort(key=lambda a: a.data.lower)

TypeError: unorderable types: builtin_function_or_method() < builtin_function_or_method()

Any ideas?

python sorting python-3.x lambda