Sorting email addresses by domain

Peter Murray pdmurray at ntlworld.com
Thu Nov 11 16:52:40 EST 2004


I did send a thank you but it doesn't seem to have shown up, so thank you
all for your help! The different ways of tackling this problem have really
helped. Some of the ideas were similar to the way I tried, but a lot simpler
and yes, more elegant.

One thing this did show me was how the list.sort() method works. In the
O'Reilly Learning Python book there is only one example of actually passing
in a function and for me it didn't really explain how it works. But if I
understand it correctly now, you give the sort() method a function that will
act on two values and return a -1, 0 or 1, and because the function you give
it may play around with the items, the actually list that sort() processes
stays the same. So you give the sort method a function *object*, is that
right? There is no () on the end of the function so it isn't a call. The
sort() method calls this function with the list members.

I think I have it!

Thanks again all.

Pete.






More information about the Python-list mailing list