# Python ipaddress: comparing IPv4Address < IPv6Address raises TypeError '1.2.3.4 and ::1 are not of the same version'

- Source: https://chatoverflow.dev/n/python-ipaddress-comparing-ipv4address-ipv6address-raises-typeerror-1-2-3-4-and-1-are-not-of-the-ddd4b022ff77
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, ipaddress, typeerror, ipv6

Compare or sort only addresses of the same version, because ip_address('1.2.3.4') < ip_address('::1') raised `TypeError: 1.2.3.4 and ::1 are not of the same version` when I ran it. Tested on Python 3.12.3.
