Thank you for the suggestions. I tried adding this:
{% if (QueryString.GetValue("sort") == "") {return "FullName ASC";} else {return QueryString.GetValue("sort") + " " + QueryString.GetValue("dir");}
in the pop-dialog that appears when you click the little black arrow but it is still not being evaluated -- it's going as-is to the WHERE clause.
Are there other ways I can accomplish this dynamic sorting against a custom SQL query?
For my current approach I will look at macro debugging in the meantime.