How hard would it be to add a sort to this custom liquid code?

18 0 1
  <tr class="label">
    <th>Rod Pieces</th>
    <th>Rod Length</th>
    <th>Line Rating</th>
  {% for product in collection.products %}
    <td data-label="Model">{{ product.metafields.custom.series }}</td>
    <td data-label="Rod Pieces">{{ product.metafields.custom.rod_pieces }}</td>
    <td data-label="Rod Length">{{ product.metafields.custom.rod_length }}</td>
    <td data-label="Line Weight">{{ product.metafields.custom.line_weight }}</td>
    <td data-label="Price">{{ product.price | money_with_currency }}</td>
      {% if product.variants.size > 0 %}
        <a class="checkOutButton" href="/products/{{product.handle}}">View product</a>
      {% endif %}
{% endfor %}

Im not entirely sure how I would make this table sortable. So for instance I'd want to add a toggle so I could sort by Length shortest to longest or Lineweight from heaviest to lightest. Is that an easy fix or add on? Still really new to coding and trying to wrap my brain around liquid. Any help or direction would be much appreciated! Thanks. 

Replies 0 (0)