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


{% 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?


1 Answer 1


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 }}') %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.