Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 21722

Scripting • Re: I want to sort the speed measurement results from high to low, but I find it impossible to do so no matter what!

$
0
0
AI has no idea about Ros scripting. Not even the basics.

I suggest you use the built-in sorting of dictionary arrays:
Code:
:global l ({}):set ($l->"c") "three":set ($l->"a") "one":set ($l->"b") "two":foreach k,v in=$l do={:put ("$k:$v")}
Output:
Code:
a:oneb:twoc:three
What you have to do is:
- get the speed of an interface, ($speed)
- subtract it from a big enough number so that subtracting does not result in decreasing the number of digits ( something like :set speed (99999 - $speed) )
- collect data into a dictionary array (for example :set ($l->$speedstr) $interfacename ).

The result will be an array sorted by speed string, lower to higher. If you

Note: it i important to use string, otherwise you'll end up with a huge, number indexed array with lots of empty items.

Statistics: Posted by A9691 — Fri Mar 28, 2025 8:52 am



Viewing all articles
Browse latest Browse all 21722

Trending Articles