marvin-zhao / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

Sorting ips with different versions: TypeError: are not of the same version #103

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add IPv6 and IPv4 addresses into a list
2. Sort a list

What is the expected output? What do you see instead?

I expect ips are sorted transparently, I should not worry about different IP 
versions.

Instead I see TypeError: are not of the same version

Original issue reported on code.google.com by Van...@gmail.com on 15 Mar 2013 at 1:20

GoogleCodeExporter commented 9 years ago
I'm not sure how it should be sorted though...

Original comment by Van...@gmail.com on 15 Mar 2013 at 1:29

GoogleCodeExporter commented 9 years ago
You can sort a mixed IPv4 and IPv6 list by specifying the sort key:

sorted_list = sorted(addr_list, key=ipaddr.get_mixed_type_key)

Original comment by gurub...@gmail.com on 20 Mar 2013 at 9:33

GoogleCodeExporter commented 9 years ago
Great, thanks

Original comment by Van...@gmail.com on 20 Mar 2013 at 9:37