Re: Help with sorting


Subject: Re: Help with sorting
From: Troy Melhase (troy@gci.net)
Date: Tue Feb 24 2004 - 12:15:38 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

>
> I cannot code and need a way to parse out a long list, here is a
> snippetof that list.
>
> ('C952tenblpl.zap2it.com', 'TENBLPL', '952'),
> ('C953tenblox.zap2it.com', 'TENBLOX', '953'),
> ('C99oln.zap2it.com', 'OLN', '99'),
> ('C9loor009.zap2it.com', 'LOOR009', '9'),
>
> I want to be able to parse on the last number of each one of these
> linesand sort them from 1-953. Can someone give me a hand with this?
>
> Jon
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>

---------
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:15:43 AKST