Bogdan,<div>Thanks for this.. I'll give it a shot. This should be pretty fast, right?</div><div><br></div><div>I didn't understand in the set_select_weight function what sets the weight of each element. ?</div><div>
<br></div><div>Thanks!</div><div>-Brett</div><div><br><br><div class="gmail_quote">On Fri, May 14, 2010 at 3:38 AM, Bogdan-Andrei Iancu <span dir="ltr"><<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Brett,<br>
<br>
There is no such builtin functionality - what we have is for weight-base<br>
selection (see<br>
<a href="http://www.opensips.org/html/docs/modules/1.6.x/cfgutils.html#id228612" target="_blank">http://www.opensips.org/html/docs/modules/s1.6.x/cfgutils.html#id228612</a>).<br>
<br>
What I can suggest (as a fast solution) is to implement a bubble-sort<br>
algh in the script:<br>
<br>
$var(changed) = 1;<br>
while ( $var(changed)==1 ) {<br>
$var(i) = 0;<br>
$var(changed) = 0;<br>
while ( $(avp(s:price)[$var(i)+1])!=NULL ) {<br>
if ( $(avp(s:price)[$var(i)]) > $(avp(s:price)[$var(i)+1]) )<br>
$var(tmp) = $(avp(s:price)[$var(i)+1]);<br>
$(avp(s:price)[$var(i)+1]) = $(avp(s:price)[$var(i)]) ;<br>
$(avp(s:price)[$var(i)]) = $var(tmp);<br>
$var(changed) = 1;<br>
}<br>
$var(i) = $var(i) + 1;<br>
}<br>
}<br>
<br>
haven't tried that so far :P<br>
<br>
Regards,<br>
Bogdan<br>
<div><div></div><div class="h5"><br>
Brett Nemeroff wrote:<br>
> Hello All,<br>
> I'm looking to numerically sort data.. Basically what I need is an<br>
> array with numerical data values to be sorted (yes, for pricing)<br>
><br>
><br>
> $avp(s:price)[0]=0.0125<br>
> $avp(s:price)[1]=0.0138<br>
> $avp(s:price)[2]=0.0128<br>
> $avp(s:price)[3]=0.0112<br>
> $avp(s:price)[4]=0.0005<br>
> $avp(s:price)[5]=0.0149<br>
><br>
><br>
> And I'd like to....<br>
><br>
> <magic><br>
> $avp(s:price_sorted) = avp_sort("$avp(s:price)");<br>
> </magic><br>
><br>
> Is that possible with.. anything? It doesn't need to be an AVP.. just<br>
> looking for any sortable data structure.<br>
><br>
> Thanks,<br>
> Brett<br>
><br>
><br>
</div></div>> ------------------------------------------------------------------------<br>
<div class="im">><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
><br>
<br>
<br>
--<br>
</div><font color="#888888">Bogdan-Andrei Iancu<br>
<a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br></div>