// Code generated by godown. Extracted from go1.26.5 net/netip. DO NOT EDIT.

package netip

import (
	"cmp"
	"net/netip"
)

func PrefixCompare(p netip.Prefix, p2 netip.Prefix) int {
	// Aside from sorting based on the masked address, this use of
	// Addr.Compare also enforces the valid vs. invalid and address
	// family ordering for the prefix.
	if c := p.Masked().Addr().Compare(p2.Masked().Addr()); c != 0 {
		return c
	}

	if c := cmp.Compare(p.Bits(), p2.Bits()); c != 0 {
		return c
	}

	return p.Addr().Compare(p2.Addr())
}
