Bogdan,<div>Thanks for this.. I&#39;ll give it a shot. This should be pretty fast, right?</div><div><br></div><div>I didn&#39;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">&lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;</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)]) &gt; $(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&#39;t tried that so far :P<br>
<br>
Regards,<br>
Bogdan<br>
<div><div></div><div class="h5"><br>
Brett Nemeroff wrote:<br>
&gt; Hello All,<br>
&gt; I&#39;m looking to numerically sort data.. Basically what I need is an<br>
&gt; array with numerical data values to be sorted (yes, for pricing)<br>
&gt;<br>
&gt;<br>
&gt; $avp(s:price)[0]=0.0125<br>
&gt; $avp(s:price)[1]=0.0138<br>
&gt; $avp(s:price)[2]=0.0128<br>
&gt; $avp(s:price)[3]=0.0112<br>
&gt; $avp(s:price)[4]=0.0005<br>
&gt; $avp(s:price)[5]=0.0149<br>
&gt;<br>
&gt;<br>
&gt; And I&#39;d like to....<br>
&gt;<br>
&gt; &lt;magic&gt;<br>
&gt; $avp(s:price_sorted) = avp_sort(&quot;$avp(s:price)&quot;);<br>
&gt; &lt;/magic&gt;<br>
&gt;<br>
&gt; Is that possible with.. anything? It doesn&#39;t need to be an AVP.. just<br>
&gt; looking for any sortable data structure.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Brett<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
<div class="im">&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<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>