Re: Help with sorting


Subject: Re: Help with sorting
jonr@destar.net
Date: Tue Feb 24 2004 - 12:43:34 AKST


>
> #!/usr/bin/env python
>
> datafile = file('mydatafilename', 'r')
> data = file.read()
> datafile.close()
>
> seq = eval(data)
> map = {}
> for host, foo, index in seq:
> map[int(index)] = (host, foo)
>
> map = [(k, v, d) for k, (v, d) in map.items()]
> map.sort()
>
> import pprint
> pprint.pprint( map )
>
> ## hope this helps
>
> ----- Original Message -----
> From: jonr@destar.net
> Date: Tuesday, February 24, 2004 12:17 pm
> Subject: Help with sorting
>

Thanks for the reply Troy,

If the file name was 'test' how would I make this work? What values do I
have to put into the script to make it read my 'test' file? Do I need to
put something in for 'host' and 'foo'? Sorry for all the questions but
like I said my skillz at writing any type of code or /dev/null.

Jon
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Tue Feb 24 2004 - 12:32:59 AKST