<p>You can't do that with core Craft functionality or Twig filters, but as Mats already suggested in the comments, you can do it with a plugin like <a href="http://michaelrog.com/craft/lagniappe/supersort" rel="nofollow">"Super Sort"</a>.</p>

<p>The template code to sort the array returned from the table field with that plugin would be:</p>

<pre><code>{% for row in entry.tablefield|supersort('sortAs', '{{ object.firstName }}') %}
</code></pre>

CC BY-SA 3.0
2015-05-07T20:36:07.710Z
2015-05-07T21:03:37.157Z
2015-05-07T21:03:37.157Z
carlcs
<p>Guess this is a stupid question, but I'm trying to sort a table based on which column the user wants to sort.</p>

<p>Tried:</p>

<p><code>{% for row in entry.tablefield|sort %}</code> (No effect)</p>

<p><code>{% for row in entry.tablefield.order('firstName') %}</code> (Error message)</p>

<p>Anyone who know if this is possible or know how to do this?</p>

CC BY-SA 3.0
2015-05-07T20:30:26.170Z
Have you looked at the [SuperSort plugin](http://michaelrog.com/craft/lagniappe/supersort)?
Mats Mikkel Rummelhoff
<templating><sorting>
Want to sort a table field from Twig
# Want to sort a table field from Twig

(Asked by: username_0 on 2015-05-07)

Guess this is a stupid question, but I'm trying to sort a table based on which column the user wants to sort.

Tried:

`{% for row in entry.tablefield|sort %}` (No effect)

`{% for row in entry.tablefield.order('firstName') %}` (Error message)

Anyone who know if this is possible or know how to do this?

**Tags:** templating, sorting
> **Comments:**
> **username_1**: Have you looked at the [SuperSort plugin](http://michaelrog.com/craft/lagniappe/supersort)?  

---

## 1 answers

### Answer by username_2 on 2015-05-07. Score: 6 | Accepted answer

You can't do that with core Craft functionality or Twig filters, but as Mats already suggested in the comments, you can do it with a plugin like "Super Sort".
The template code to sort the array returned from the table field with that plugin would be:
{% for row in entry.tablefield|supersort('sortAs', '{{ object.firstName }}') %}


---

