[Tutor] IP sorting

Karthik Gurumurthy karthikg@aztec.soft.net
Thu, 27 Dec 2001 12:17:34 +0530

this one is cool and so was danny's.
i have a question here though.

why do we need to convert to a tuple?

lot = [tuple(map(int, ip.split("."))) for ip in iplist]

is there any specific reason. Python does not know to sort a list of lists?


-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Roman Suzi
Sent: Thursday, December 27, 2001 11:46 AM
To: tutor@python.org
Subject: RE: [Tutor] IP sorting

Nice problem! Here is my solution (for Python 2.x)

iplist = [

lot = [tuple(map(int, ip.split("."))) for ip in iplist]
iplist1 = [".".join(map(str, addr)) for addr in lot]

print iplist1

Sincerely yours, Roman A.Suzi
 - Petrozavodsk - Karelia - Russia - mailto:rnd@onego.ru -

Tutor maillist  -  Tutor@python.org