Sometimes it may be useful to use query parameter values in your liquid template within Shopify, however Shopify does not expose this information.
Conveniently the content_for_header
output actually includes the full page url that is being used, so with a chain of liquid filters we can actually extract this information into something we can use.
Copy the file below into your snippets folder, and on any template that you need to access query strings, simply use the following code:
{% include 'query-to-variables' %}
Sorting by {{ paramSortBy }}