Community discussions

MikroTik App
 
patrick7
Member
Member
Topic Author
Posts: 343
Joined: Sat Jul 20, 2013 2:40 pm

Feature request: Add sorting

Tue Sep 06, 2016 5:09 pm

Hi there

I hereby request a feature which is really important in my opinion.
It should be possible to use sorting anywhere in the CLI. I don't think "print where list=ABC" is a really good solution.

- Address lists should be autosorted, so that entries from the same list are being printed continously, like Cisco access lists
- BGP peers should be autosorted (Remote-AS, or IP, or Name), like Cisco does.
- IP addresses should be sorted
- ARP entries shouuld be sorted
- DHCP leases should be sorted
- ...xyz should also be sorted :-)

Best regards
Patrick
 
User avatar
NeoXiD
just joined
Posts: 2
Joined: Tue Sep 06, 2016 8:15 pm

Re: Feature request: Add sorting

Tue Sep 06, 2016 8:52 pm

I think this is a really great and long-needed idea, as I prefer CLI over Winbox or the Web UI. Some sections should be definitely auto-sorted too - it doesn't make sense to display address lists all mixed up instead of showing them consecutively. I think Mikrotik should settle with three different ways:
  • Auto-sorted entries like address lists, e.g. alphanumerically ascending (to keep the address lists together and make them easier to read), in case of address lists probably even first by name, then by IP address (lowest to highest IP for example)
  • Temporary sorting while printing configurations at various places, without affecting the entry permanently, e.g. print all IP addresses sorted by their comment, descending alphanumerically.
  • Permanent sorting, e.g. you can specify some options and the entries get permanently reordered
This should cover all use cases and would be a great addition. Configuration gets really hard to read when you have a lot of entries, e.g. many BGP peers or big address lists. And there's not even manual moving, so you have to deal with it or export them, remove all entries and re-import... obviously not great for BGP.
 
patrick7
Member
Member
Topic Author
Posts: 343
Joined: Sat Jul 20, 2013 2:40 pm

Re: Feature request: Add sorting

Tue Sep 27, 2016 8:06 pm

Thanks NeoXiD. Anyonen else? I think if more people wish this feature, possibility will be higher for it to be implemented.
 
User avatar
Cha0s
Forum Guru
Forum Guru
Posts: 1142
Joined: Tue Oct 11, 2005 4:53 pm

Re: Feature request: Add sorting

Wed Sep 28, 2016 1:59 pm

+1 :)
 
pe1chl
Forum Guru
Forum Guru
Posts: 10233
Joined: Mon Jun 08, 2015 12:09 pm

Re: Feature request: Add sorting

Wed Sep 28, 2016 2:13 pm

It looks like all lists are auto-sorted, but unfortunately they are sorted by # (ID).
It would certainly be nice to be able to "order by fieldname,fieldname" in the CLI.
However, it looks like the sorting in Winbox and WebUI is done by the client.
RouterOS may not have the infrastructure to hold command output and sort it before sending to the user...
Remember that some commands produce a lot of output and can be paused for arbitrary time due to
pagination, so it can commit quite some router memory to pending sorted output.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Feature request: Add sorting

Sat May 18, 2019 9:03 pm

This I would like too.
 
SIN3R6Y
just joined
Posts: 2
Joined: Thu Sep 28, 2023 2:58 am

Re: Feature request: Add sorting

Tue Oct 10, 2023 8:09 am

it's 2023 and this would be super useful. With the CRS series now out and support layer 3 hardware routing, things like the address lists are growing larger and larger.

Some sorting i would like to see by default.

Bridge VLAN list by vlan id, ascending.
Address list by address, ascending.
ip pools by pool name ascending.

There are probably more places this could be done. When configs are pushing hundreds of lines, i end up having to copy /export into a text editor and sorting there to gain better readability.
 
User avatar
robmaltsystems
Long time Member
Long time Member
Posts: 574
Joined: Fri Jun 21, 2019 12:04 pm

Re: Feature request: Add sorting

Sun Feb 04, 2024 3:52 pm

2024 and I'd still like this feature. Just done /file/print and wanted it sorted please. After all the GUI interface is sorted - sort of. It's case-sensitive sort.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10233
Joined: Mon Jun 08, 2015 12:09 pm

Re: Feature request: Add sorting

Sun Feb 04, 2024 8:47 pm

Still, the sorting in winbox is done by winbox, not by RouterOS.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3460
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Feature request: Add sorting

Sun Feb 04, 2024 9:34 pm

Surprisingly, never run into this need myself. But I can see some "sortby=" on a print be helpful.

One note is that the "print" is ordered by when they were added. While not ideal, you add (or remove+re-add) them in the order you'd to see later. Obviously, does not solve some generic ORDER BY.

Also far from ideal, but you could sort print at CLI, indirectly, using an array – since scripting arrays are sorted alphabetically by default. Jjust no good way to do "pretty" output.
/interface {
    :local sortby "name"
    :local arr [:toarray ""]
    :foreach k,v in=[print as-value] do={
        :set ($arr->($v->$sortby)) $v 
    }
    :foreach k,v in=$arr do={:put "$k \t$[:tostr $v]" }
}
back-to-home-vpn .id=*bf;actual-mtu=1420;comment=back-to-home-vpn;name=back-to-home-vpn;type=wg
bridge .id=*e;actual-mtu=1500;comment=defconf;l2mtu=1592;mac-address=XX;name=bridge;type=bridge
ether1 .id=*1;actual-mtu=1500;comment=;l2mtu=1592;mac-address=XX;max-l2mtu=9578;name=ether1;type=ether
ether10 .id=*a;actual-mtu=1500;comment=;l2mtu=1592;mac-address=XX;max-l2mtu=9578;name=ether10;type=ether
ether11 .id=*b;actual-mtu=1500;comment=;l2mtu=1592;mac-address=XX;max-l2mtu=9578;name=ether11;type=etherr
[...]
ether2 .id=*2;actual-mtu=1500;comment=;l2mtu=1592;mac-address=XX;max-l2mtu=9578;name=ether2;type=ether
ether3 .id=*3;actual-mtu=1500;comment=;l2mtu=1592;mac-address=XX;max-l2mtu=9578;name=ether3;type=ether
veth-traefik .id=*aa;actual-mtu=1500;comment=;mac-address=XX;name=veth-traefik;type=veth

Who is online

Users browsing this forum: BoraHorza, Deantwo and 123 guests