<p>I went and looked at the <a href="http://buildwithcraft.com/docs/templating/matrixblockmodel" rel="nofollow">MatrixBlockModel</a>; there's an attribute named <a href="http://buildwithcraft.com/docs/templating/matrixblockmodel#sortOrder" rel="nofollow">sortOrder</a> (If you output <code>{{sortOrder}}</code> inside the <code>for</code> loop, it will display the index of that block).</p>

<p>You can use that attribute to sort by, in reverse:</p>

<pre><code>{% for cta in entry.ctas.order('sortOrder desc') %}
</code></pre>

CC BY-SA 3.0
2014-10-28T12:44:29.603Z
2014-10-28T12:44:29.603Z
darylknight
<p>I've using a matrix field from the same entry in two different templates. In one template I want them in the order they're displaying in the CMS, while in the other I want them displayed in reverse.</p>

<p>It doesn't like this:</p>

<pre><code>{% for cta in entry.ctas.order('desc') %}
</code></pre>

<p>Can this be done any other way?</p>

<matrix><sorting><order>
How to order matrix blocks in reverse
# How to order matrix blocks in reverse

(Asked by: username_0 on 2014-10-28)

I've using a matrix field from the same entry in two different templates. In one template I want them in the order they're displaying in the CMS, while in the other I want them displayed in reverse.
It doesn't like this:
{% for cta in entry.ctas.order('desc') %}

Can this be done any other way?

**Tags:** matrix, sorting, order

---

## 1 answers

### Answer by username_1 on 2014-10-28. Score: 3 | Accepted answer

I went and looked at the MatrixBlockModel; there's an attribute named sortOrder (If you output {{sortOrder}} inside the for loop, it will display the index of that block).
You can use that attribute to sort by, in reverse:
{% for cta in entry.ctas.order('sortOrder desc') %}


---

