Go 1.26 introduces a new Compare method for the netip.Prefix type, enabling standardized comparison and sorting of IP subnets. The method follows IANA conventions and Python's netaddr implementation, ordering prefixes by validity, address family (IPv4 before IPv6), masked IP address, prefix length, and unmasked address. This eliminates the need for developers to write custom comparison logic when organizing routing tables or sorting IP subnets.
Sort: