Refactor some search stuff

how so? Maybe wrapping it in a single `if data.get('sort')` will help clarify.

I should also check if we actually allow multiple sorts. This assumes so below, but above it does not.