If you have multiple (regex) patterns then it'll sort them alphabetically relative to each other.
e.g.
(regex).json
(regex).txt
will sort a.txt before b.json
I believe this happens because regex files are found by sorting alphabetically and then going through each file to find matches. I think you just need to switch the inner/outer loop and have it scan through regex lines as the outer loop.