func SortOrderMostPublic(a Address) int {
	order := 100

	switch a.AddressScope() {
	case ScopePublic:
		order = 0
		// Special case to ensure that these follow non-localhost host names.
		if a.AddressIsSecondary() {
			order = 10
		}
	case ScopeCloudLocal:
		order = 30
	case ScopeFanLocal:
		order = 50
	case ScopeMachineLocal:
		order = 70
	case ScopeLinkLocal:
		order = 90
	}

	switch a.AddressType() {
	case HostName:
		order = 10
		if a.Host() == "localhost" {
			order = 20
		}
	case IPv6Address:
		order++
	case IPv4Address:
	}

	if a.AddressIsSecondary() {
		order += 2
	}

	return order
}
// SortOrderMostPublic calculates the "weight" of the address to use when
// sorting such that the most accessible addresses will appear first:
// - public IPs first;
// - hostnames after that, but "localhost" will be last if present;
// - cloud-local next;
// - fan-local next;
// - machine-local next;
// - link-local next;
// - non-hostnames with unknown scope last.
// Secondary addresses with otherwise equal weight will be sorted to come after
// primary addresses, including host names *except* localhost.
SortOrderMostPublic calculates the "weight" of the address to use when
sorting such that the most accessible addresses will appear first:
- public IPs first;
- hostnames after that, but "localhost" will be last if present;
- cloud-local next;
- fan-local next;
- machine-local next;
- link-local next;
- non-hostnames with unknown scope last.
Secondary addresses with otherwise equal weight will be sorted to come after
primary addresses, including host names *except* localhost.
// SortOrderMostPublic calculates the " weight " of the address to use when // sorting such that the most accessible addresses will appear first : // - public IPs first ; // - hostnames after that but " localhost " will be last if present ; // - cloud - local next ; // - fan - local next ; // - machine - local next ; // - link - local next ; // - non - hostnames with unknown scope last . // Secondary addresses with otherwise equal weight will be sorted to come after // primary addresses including host names * except * localhost .
func SortOrderMostPublic(a Address) int {
	order := 100
	switch a.AddressScope() {
	case ScopePublic:
		order = 0
		if a.AddressIsSecondary() {
			order = 10
		}
	case ScopeCloudLocal:
		order = 30
	case ScopeFanLocal:
		order = 50
	case ScopeMachineLocal:
		order = 70
	case ScopeLinkLocal:
		order = 90
	}
	switch a.AddressType() {
	case HostName:
		order = 10
		if a.Host() == "localhost" {
			order = 20
		}
	case IPv6Address:
		order++
	case IPv4Address:
	}
	if a.AddressIsSecondary() {
		order += 2
	}
	return order
}
func SortOrderMostPublic ( a Address ) int { order := 100 switch a . AddressScope ( ) { case ScopePublic : order = 0 if a . AddressIsSecondary ( ) { order = 10 } case ScopeCloudLocal : order = 30 case ScopeFanLocal : order = 50 case ScopeMachineLocal : order = 70 case ScopeLinkLocal : order = 90 } switch a . AddressType ( ) { case HostName : order = 10 if a . Host ( ) == " " { order = 20 } case IPv6Address : order ++ case IPv4Address : } if a . AddressIsSecondary ( ) { order += 2 } return order }
SortOrderMostPublic calculates the "weight" of the address to use when
sorting such that the most accessible addresses will appear first:
 public IPs first;
 hostnames after that, but "localhost" will be last if present;
 cloud-local next;
 fan-local next;
 machine-local next;
 link-local next;
 non-hostnames with unknown scope last.
SortOrderMostPublic calculates the " weight " of the address to use when sorting such that the most accessible addresses will appear first : public IPs first ; hostnames after that but " localhost " will be last if present ; cloud - local next ; fan - local next ; machine - local next ; link - local next ; non - hostnames with unknown scope last .
// Special case to ensure that these follow non-localhost host names.