Heh, I guess that won&#39;t work. :) <div><br></div><div><br></div><div>I&#39;ll try the bubblesort.. </div><div><br></div><div>Thanks,</div><div>Brett</div><div><br><br><div class="gmail_quote">On Fri, May 14, 2010 at 9:28 AM, Anca Vamanu <span dir="ltr">&lt;<a href="mailto:anca@opensips.org">anca@opensips.org</a>&gt;</span> wrote:<br>

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