code: func (epi *endpoint) Less(epj *endpoint) bool {
  	var (
  		prioi, prioj int
  	)
  
  	sbi, _ := epi.getSandbox()
  	sbj, _ := epj.getSandbox()
  
  	// Prio defaults to 0
  	if sbi != nil {
  		prioi = sbi.epPriority[epi.ID()]
  	}
  	if sbj != nil {
  		prioj = sbj.epPriority[epj.ID()]
  	}
  
  	if prioi != prioj {
  		return prioi > prioj
  	}
  
  	gwi := epi.endpointInGWNetwork()
  	gwj := epj.endpointInGWNetwork()
  	if gwi != gwj {
  		return gwj
  	}
  
  	inti := epi.getNetwork().Internal()
  	intj := epj.getNetwork().Internal()
  	if inti != intj {
  		return intj
  	}
  
  	jii := 0
  	if epi.joinInfo != nil {
  		if epi.joinInfo.gw != nil {
  			jii = jii + 1
  		}
  		if epi.joinInfo.gw6 != nil {
  			jii = jii + 2
  		}
  	}
  
  	jij := 0
  	if epj.joinInfo != nil {
  		if epj.joinInfo.gw != nil {
  			jij = jij + 1
  		}
  		if epj.joinInfo.gw6 != nil {
  			jij = jij + 2
  		}
  	}
  
  	if jii != jij {
  		return jii > jij
  	}
  
  	return epi.network.Name() < epj.network.Name()
  }
docs: // <=> Returns true if a < b, false if a > b and advances to next level if a == b
  // epi.prio <=> epj.prio           # 2 < 1
  // epi.gw <=> epj.gw               # non-gw < gw
  // epi.internal <=> epj.internal   # non-internal < internal
  // epi.joininfo <=> epj.joininfo   # ipv6 < ipv4
  // epi.name <=> epj.name           # bar < foo