static int winsdb_addr_sort_list (struct winsdb_addr **p1, struct winsdb_addr **p2, void *opaque)
{
	struct winsdb_addr *a1 = talloc_get_type(*p1, struct winsdb_addr);
	struct winsdb_addr *a2 = talloc_get_type(*p2, struct winsdb_addr);
	struct winsdb_handle *h= talloc_get_type(opaque, struct winsdb_handle);
	bool a1_owned = false;
	bool a2_owned = false;

	/*
	 * first the owned addresses with the newest to the oldest address
	 * then the replica addresses with the newest to the oldest address
	 */
	if (a2->expire_time != a1->expire_time) {
		return a2->expire_time - a1->expire_time;
	}

	if (strcmp(a2->wins_owner, h->local_owner) == 0) {
		a2_owned = true;
	}

	if (strcmp(a1->wins_owner, h->local_owner) == 0) {
		a1_owned = true;
	}

	return a2_owned - a1_owned;
}
static int winsdb_addr_sort_list (struct winsdb_addr **p1, struct winsdb_addr **p2, void *opaque)
{
	struct winsdb_addr *a1 = talloc_get_type(*p1, struct winsdb_addr);
	struct winsdb_addr *a2 = talloc_get_type(*p2, struct winsdb_addr);
	struct winsdb_handle *h= talloc_get_type(opaque, struct winsdb_handle);
	bool a1_owned = false;
	bool a2_owned = false;

	 
	if (a2->expire_time != a1->expire_time) {
		return a2->expire_time - a1->expire_time;
	}

	if (strcmp(a2->wins_owner, h->local_owner) == 0) {
		a2_owned = true;
	}

	if (strcmp(a1->wins_owner, h->local_owner) == 0) {
		a1_owned = true;
	}

	return a2_owned - a1_owned;
}