Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-09 Thread Peter Otten
Ben Finney wrote: > mosscliffe <[EMAIL PROTECTED]> writes: > >> 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 ? >> >> mylist = ['Fred','bill','PAUL','albert'] >> >> mylist.sort(

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Hendrik van Rooyen
"Joe" <[EMAIL PROTECTED]> wrote: > I am new to lambda and have searched for a few hours this morning, coming up > empty handed. Is this possible? Seeing as it has happened, it must be. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Ben Finney
mosscliffe <[EMAIL PROTECTED]> writes: > 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 ? > > mylist = ['Fred','bill','PAUL','albert'] > > mylist.sort(key=lambda el: el.lower()) He

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread mosscliffe
On 8 Jun, 16:39, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, 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

RE: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Joe
> > Now, I would like to be able to specify which index to sort by. I am > not > > able to pass in external variables like: > > > > List.sort(key=lambda el: el[indexNumber].lower()) > > Why ever not? Sorry, I should have written back with my findings. I had run into the problem described in thi

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Simon Brunning
On 6/8/07, Joe <[EMAIL PROTECTED]> wrote: > Now, I would like to be able to specify which index to sort by. I am not > able to pass in external variables like: > > List.sort(key=lambda el: el[indexNumber].lower()) Why ever not? -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net

RE: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Joe
> Try: > > list.sort(key=lambda el: el[0].lower()) Now, I would like to be able to specify which index to sort by. I am not able to pass in external variables like: List.sort(key=lambda el: el[indexNumber].lower()) I am new to lambda and have searched for a few hours this morning, coming up em

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 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 functio

RE: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Joe
> Try: > > list.sort(key=lambda el: el[0].lower()) Thanks! Worked like a charm :) > BUT - it's not a good idea to use list as a name, 'cos list is a > built-in, and you're obscuring it. Oh, don't worry. That was strictly my portrayal of the problem. Thanks again! Jough -- http://mail.pyth

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread mosscliffe
On 8 Jun, 14:18, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > On 6/7/07, Joe <[EMAIL PROTECTED]> wrote: > > > > > I have a list of lists that I would like to sort utilizing a certain index > > of the nested list. I am able to successfully use: > > > Import operator > > list = [["Apple", 1], ["air

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Simon Brunning
On 6/7/07, Joe <[EMAIL PROTECTED]> wrote: > > I have a list of lists that I would like to sort utilizing a certain index > of the nested list. I am able to successfully use: > > Import operator > list = [["Apple", 1], ["airplane", 2]] > list.sort(key=operator.itemgetter(0)) > > But, unfortunately,