I haven't found a clean way of sorting firewall rules by a specific property, so I made a script to show me the output I want. Also, this works great if executed remotely as you can retrieve specific information for input into other systems.
Try this:
# Displays a sorted firewall list
/interface {
:local ifacename
:local property
:local value
:local findindex
:local curline
:foreach i in=[find] do={
:set ifacename [get $i name]
/ip firewall filter {
:local ruledisabled
:foreach f in=[print as-value where in-interface=[:tostr $ifacename]] do={
:set curline ""
:set ruledisabled ""
:foreach item in=[:toarray $f] do={
:set findindex [:find [:tostr $item] "="]
:set property [:pick [:tostr $item] 0 $findindex]
:set value [:pick [:tostr $item] ($findindex + 1) [:len [:tostr $item]]]
# don't show IDs or comments (provides a cleaner output)
:if ($property != ".id" && $property != "comment") do={
:set curline ($curline . " " . $property . "=" . $value)
}
# print as-value doesn't show disabled status; get rule's disabled status
:if ($property = ".id") do={
:if ([get [:toid $value] disabled] = true) do={
:set ruledisabled "disabled=true" } else={
:set ruledisabled "disabled=false" }
}
}
:put ($curline . " " . $ruledisabled)
}
}
}
}