Add a sequence number to each rule during rule sort. Fix #16076
The 'for' loop first checks if the rule at that iteration exists and breaks if not. When the rules array contains a gap, the 'for' loop breaks early and potentially misses additional rules that need to be sorted. Fix this issue by switching to a 'foreach' loop.
Related issues
Bug #16076: Deleting or adding a firewall rule may result in an unexpected rule order
Add a sequence number to each rule during rule sort. Fix #16076
The 'for' loop first checks if the rule at that iteration exists and
breaks if not. When the rules array contains a gap, the 'for' loop breaks
early and potentially misses additional rules that need to be sorted. Fix
this issue by switching to a 'foreach' loop.