On Thu, May 8, 2008 at 11:53 PM, Kushal Das <[EMAIL PROTECTED]> wrote:
> Hi,
>  What is the best way to sort IP numbers
>  numbers like
>  192.168.20.1
>  192.168.1.1
>  172.18.13.2

ips = ['192.168.20.1', '192.168.1.1', '172.18.13.2']
sorted(ips, key=lambda ip: [int(x) for x in ip.split('.')])

# ips.sort(key=lambda ip: [int(x) for x in ip.split('.')]) if you want
to sort in-place.
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to