In <058a4a9e-7893-44ef-97c0-999a3589e...@googlegroups.com> Josh English 
<joshua.r.engl...@gmail.com> writes:

> print list(sorted(all_the_stuff, key=lambda x: x.name.lower))
> print list(sorted(all_the_stuff, key=lambda x: x.name.lower()))

> # END

> The output is:

> [Thing d, Thing f, Thing 2, Thing a, Thing b, Thing C]
> [Thing 2, Thing a, Thing b, Thing C, Thing d, Thing f]

> Any ideas why I'm seeing two different results? Especially as the correct
> form is giving me the wrong results?

Why do you say that 'key=lambda x: x.name.lower' is the correct form? That
returns the str.lower() function object, which is a silly thing to sort
on.  Surely you want to sort on the *result* of that function, which is
what your second print does.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gor...@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to