Case-Insensitive Sorting of Multi-Dimensional Lists

Marc 'BlackJack' Rintsch bj_666 at
Fri Jun 8 17:39:32 CEST 2007

In <1181316575.800182.167640 at>, mosscliffe

> 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()


	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list