Re: How to sort a list of strings on a substring

2009-10-06 Thread n00m
Here you are: LogList = [\ "inbound tcp office 192.168.0.125 inside 10.1.0.91 88", "inbound tcp office 192.168.0.220 inside 10.1.0.31 2967", "inbound udp lab 172.24.0.110 inside 10.1.0.6 161", "inbound udp office 192.168.0.220 inside 10.1.0.13 53"] LogList.sort(key=lambda x: x[x.

Re: How to sort a list of strings on a substring

2009-10-05 Thread n00m
In my early teen, school years "Let It Be" by The Beatles sounded for my ears (incredibly clearly and obviously!) as "Lia Ri Pip". In school I studied French, English only many years later. My inner translation of "Here you are!" is smth like "Catch it!", "Take it!", "Look at this!" etc -- http:/

Re: How to sort a list of strings on a substring

2009-10-05 Thread Steven D'Aprano
On Mon, 05 Oct 2009 21:16:38 -0700, n00m wrote: > English language is not my mother toung, so I can't grasp many subtle > nuances of it. Maybe "here you are" means to me quite a different thing > than to you. It means "here is the thing you were looking for". Anyway, nothing I wrote was meant as

Re: How to sort a list of strings on a substring

2009-10-05 Thread alex23
Steven D'Aprano wrote: > Oh please. That's a ridiculous excuse. Your post started with "Here you > are" -- the implication is that you thought it *was* a solution, not a > hint. A hint would be something like "Write a key function, perhaps using > lambda, and pass it to the sort() method using the

Re: How to sort a list of strings on a substring

2009-10-05 Thread Scott
On Oct 5, 6:05 pm, MRAB wrote: > Scott wrote: > > I create a list of logs called LogList. Here is a sample: > > > LogList = > > ["inbound tcp office 192.168.0.125 inside 10.1.0.91 88", > > "inbound tcp office 192.168.0.220 inside 10.1.0.31 2967", > > "inbound udp lab 172.24.0.110 inside 10.1.0.6 1

Re: How to sort a list of strings on a substring

2009-10-05 Thread n00m
English language is not my mother toung, so I can't grasp many subtle nuances of it. Maybe "here you are" means to me quite a different thing than to you. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to sort a list of strings on a substring

2009-10-05 Thread Steven D'Aprano
On Mon, 05 Oct 2009 20:33:51 -0700, n00m wrote: >> No, that's incorrect. Try it with this data and you will see it fails: > > Of course, you are right, but I think the topic-starter is smart enough > to understand that I suggested only a hint, a sketch, a sample of how to > use "key=" with "lambd

Re: How to sort a list of strings on a substring

2009-10-05 Thread n00m
> No, that's incorrect. Try it with this data and you will see it fails: Of course, you are right, but I think the topic-starter is smart enough to understand that I suggested only a hint, a sketch, a sample of how to use "key=" with "lambda", not a ready-to-apply solution. -- http://mail.python.

Re: How to sort a list of strings on a substring

2009-10-05 Thread Steven D'Aprano
On Mon, 05 Oct 2009 15:45:58 -0700, n00m wrote: > Here you are: > > LogList = [\ > "inbound tcp office 192.168.0.125 inside 10.1.0.91 88", "inbound tcp > office 192.168.0.220 inside 10.1.0.31 2967", "inbound udp lab > 172.24.0.110 inside 10.1.0.6 161", "inbound udp office 192.168.0.22

Re: How to sort a list of strings on a substring

2009-10-05 Thread MRAB
Scott wrote: I create a list of logs called LogList. Here is a sample: LogList = ["inbound tcp office 192.168.0.125 inside 10.1.0.91 88", "inbound tcp office 192.168.0.220 inside 10.1.0.31 2967", "inbound udp lab 172.24.0.110 inside 10.1.0.6 161", "inbound udp office 192.168.0.220 inside 10.1.0.

How to sort a list of strings on a substring

2009-10-05 Thread Scott
I create a list of logs called LogList. Here is a sample: LogList = ["inbound tcp office 192.168.0.125 inside 10.1.0.91 88", "inbound tcp office 192.168.0.220 inside 10.1.0.31 2967", "inbound udp lab 172.24.0.110 inside 10.1.0.6 161", "inbound udp office 192.168.0.220 inside 10.1.0.13 53"] I want