// Then grab the first unchosen element whose running_weight >= rand_weight
// and move it into our 'picked' list
binding=root;
for(intb=0;b<count;b++){
binding=&bindings_copy[b];
if(binding->chosen)continue;// skip already picked elements
running_weight+=binding->weight;
if(running_weight>=rand_weight){
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_DEBUG,"Chose binding %d as [%s] with weight [%d] based on running weight [%d]\n",pos,binding->url,binding->weight,running_weight);
second_order[pos]=binding;
pos++;
binding->chosen=1;
break;
}
}
}
/* Then call our XML url fetch function for each binding based on our
* chosen order until we get a valid result or run out of bindings */