Re: sorting tuples...

2005-10-03 Thread nidhog
Steve Holden wrote: > Dan Sommers wrote: > > On 27 Sep 2005 19:01:38 -0700, > > [EMAIL PROTECTED] wrote: > > > > > >>with the binary stuff out of the way, what i have is this string data: > > > > > >>20050922 # date line > >>mike > >>mike's message... > >>20040825 # date line > >>jeremy > >>jeremy

Re: sorting tuples...

2005-09-28 Thread Steve Holden
Dan Sommers wrote: > On 27 Sep 2005 19:01:38 -0700, > [EMAIL PROTECTED] wrote: > > >>with the binary stuff out of the way, what i have is this string data: > > >>20050922 # date line >>mike >>mike's message... >>20040825 # date line >>jeremy >>jeremy's message... >>... > > >>what i want to do

Re: sorting tuples...

2005-09-27 Thread Dan Sommers
On 27 Sep 2005 19:01:38 -0700, [EMAIL PROTECTED] wrote: > with the binary stuff out of the way, what i have is this string data: > 20050922 # date line > mike > mike's message... > 20040825 # date line > jeremy > jeremy's message... > ... > what i want to do is to use the date line as the first

Re: sorting tuples...

2005-09-27 Thread nidhog
Magnus Lycka wrote: > Why? It seems you are trying to use a string as some kind of container, > and Python has those in the box. Just use a list of tuples, rather than > a list of strings. That will work fine for .sort(), and it's much more > convenient to access your data. Using the typical tool

Re: sorting tuples...

2005-09-26 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > I edited my code earlier and came up with stringing the groups > (200501202010, sender, message_string) into one string delimited by > '%%%'. Why? It seems you are trying to use a string as some kind of container, and Python has those in the box. Just use a list of tuple

Re: sorting tuples...

2005-09-21 Thread nidhog
Thank you very much. I'll look into this immediately. I edited my code earlier and came up with stringing the groups (200501202010, sender, message_string) into one string delimited by '%%%'. I could then sort the messages with the date string at the beginning as the one being sorted with the b

Re: sorting tuples...

2005-09-17 Thread Bengt Richter
On 17 Sep 2005 06:41:08 -0700, [EMAIL PROTECTED] wrote: >Hello guys, > >I made a script that extracts strings from a binary file. It works. > >My next problem is sorting those strings. > >Output is like: > > snip >200501221530 >John >*** long string here *** > >200504151625 >Clyde >*** cl

Re: sorting tuples...

2005-09-17 Thread bearophileHUGS
Uhm, if the file is clean you can use something like this: data = """\ 200501221530 John *** long string here *** 200504151625 Clyde *** clyde's long string here *** 200503130935 Jeremy *** jeremy string here """ records = [rec.split("\n") for rec in data.split("\n\n")] records.sort() print

sorting tuples...

2005-09-17 Thread nidhog
Hello guys, I made a script that extracts strings from a binary file. It works. My next problem is sorting those strings. Output is like: snip 200501221530 John *** long string here *** 200504151625 Clyde *** clyde's long string here *** 200503130935 Jeremy *** jeremy string here **