Case-Insensitive Sorting of Multi-Dimensional Lists

mosscliffe mcl.office at googlemail.com
Fri Jun 8 17:49:00 EDT 2007


On 8 Jun, 16:39, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> In <1181316575.800182.167... at m36g2000hse.googlegroups.com>, mosscliffe
> wrote:
>
> > I have tried the following, for a one dimensional list and it works,
> > but I can not get my head around this lambda. How would this be
> > written, without the lamda ?
>
> Well ``lambda``\s are just anonymous functions so you can write it with a
> named function of course.
>
> > mylist = ['Fred','bill','PAUL','albert']
>
> > mylist.sort(key=lambda el: el.lower())
>
> So this becomes:
>
> def keyfunc(el):
>     return el.lower()
>
> mylist.sort(key=keyfunc)
>
> Ciao,
>         Marc 'BlackJack' Rintsch

Thanks,

The mist is beginning to clear.

Richard




More information about the Python-list mailing list