> On 10 Oct 2023, at 06:15, Barry Flanagan <[email protected]> wrote:
> 
> On Fri, 6 Oct 2023, at 18:55, Alex Balashov via sr-users wrote:
>> 
>> Ah. Then the easiest approach is probably to buffer them into an XAVP 
>> array and just iterate through them. R-URI can be one attribute of 
>> each, while the destination URI/next-hop can be another. 
>> 
>>   $var(i) = 0;
>> 
>>   while(defined $xavp(route_set[$var(i)])) {
>>       $ru = $xavp(route_set[$var(i)]=>ruri);
>>       $du = $xavp(route_set[$var(i)]=>duri);
>> 
>>       $var(i) = $var(i) + 1;
>>   }
> 
> Yes, but I also need to first sort the list by weight and priority (q-value). 
> For the life of me I can't find any way to sort an array in Kamailio. Will I 
> have to use KEMI for that?

There is not a way to sort an existing an array, but you have two options:

1) Have the API call return the list already sorted;

2) Create a temporary array, then iterate over it and insert the elements from 
it into the ultimate array, in a sorted manner (i.e. insertion sort).

#1 makes the most sense to me.

As far as Kamailio config script has come with bells and whistles, it's still 
not a general-purpose programming runtime, and there will always be these kinds 
of limitations. You should conceive of Kamailio as a relatively naive consumer 
of data. As you surmise, that's why KEMI exists. However, the most natural 
answer here is to have the API return presorted data, or sort it somewhere 
along the way as part of some intermediate pipeline, before it is consumed by 
Kamailio.

-- Alex

-- 
Alex Balashov
Principal Consultant
Evariste Systems LLC
Web: https://evaristesys.com
Tel: +1-706-510-6800

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:

Reply via email to