How to do a basic "sort by" on search results page?

How to do a basic "sort by" on search results page?

eduardocoello
Tourist
9 2 2

Hello there, I just want to implement a basic "sort by" feature on the search page when the results are already displayed, like the one I already implemented in the "product.liquid" template.

Here's my code:
```

          <h3>Sort by</h3>

          <select id="sort-by">
            {% assign sort_by = search.sort_by | default: search.default_sort_by %}
            {% for option in search.sort_options %}
              <option value="{{ option.value }}" {% if option.value == sort_by %}selected="selected"{% endif %}>
                {{ option.name | escape }}
              </option>
            {% endfor %}
          </select>
```

At the moment the displayed results are not changing based on the selected option, Like I mentioned, I applied this same block on the product template and it works fine there.

What am i missing? Thank you!
Replies 0 (0)