I am a bit skeptical here. This seems too be too open. It could allow sorting by anything, also by private/hidden fields and could in this way leak some information about them. I would make information about what you can sort by part of document definition, like `PUBLISH_CATALOG_SORT` and then it can be an array of options and you pass and index. And then this option with this index is used to sort. You already have that array, so just move it to document definition. And then you can create a special check which checks that index is valid (see how I check access control index).