static int sortKey(InetAddress address,boolean prefer_v6){
  int key=address.getAddress().length;
  if (prefer_v6) {
    key=-key;
  }
  if (address.isAnyLocalAddress()) {
    key+=5;
  }
  if (address.isMulticastAddress()) {
    key+=4;
  }
  if (address.isLoopbackAddress()) {
    key+=3;
  }
  if (address.isLinkLocalAddress()) {
    key+=2;
  }
  if (address.isSiteLocalAddress()) {
    key+=1;
  }
  return key;
}

static int sortKey ( InetAddress address , boolean prefer_v6 ) { int key = address . getAddress ( ) . length ; if ( prefer_v6 ) { key = - key ; } if ( address . isAnyLocalAddress ( ) ) { key += 5 ; } if ( address . isMulticastAddress ( ) ) { key += 4 ; } if ( address . isLoopbackAddress ( ) ) { key += 3 ; } if ( address . isLinkLocalAddress ( ) ) { key += 2 ; } if ( address . isSiteLocalAddress ( ) ) { key += 1 ; } return key ; }
sorts an address by preference . this way code like publishing can just pick the first one
