You are missing that formulas are recalculated automatically. Formulas that use built-in functions are recalculated when the spreadsheet is opened and every time that a change is made.
Instead of using the sort functions of the UI, you could include in your formula SORT (the built-in function), rebuild your formula and use QUERY (another built-in function) ...
One cell solution:
Combining the FILTER Function with the COUNTIF function provides you with the list you want:
In this example I used the Key as the matching field comparing column A with matches in D but it works with the other columns as well.
was able to achieve this with a little assistance from a friend