# \-\>toStructure()-\>reverse()

**URL:** <https://forum.getkirby.com/t/tostructure-reverse/1765>\
**Category:** Questions\
**Tags:** v2\
**Created:** [August 4, 2015, 6:41pm UTC](https://forum.getkirby.com/t/tostructure-reverse/1765 "2015-08-04T18:41:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhoyLemon](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahoylemon/32/4762_2.png) [@AhoyLemon](https://forum.getkirby.com/u/AhoyLemon)\
**Post date:** [August 4, 2015, 6:41pm UTC](https://forum.getkirby.com/t/tostructure-reverse/1765/1 "2015-08-04T18:41:16Z")

</div>

Hiya,

I’m working on some structure with @timoetting’s terrific [builder](http://forum.getkirby.com/t/plugin-for-an-extended-structure-field-with-more-then-one-kind-of-field-set/1696) plugin, and I hit a little wall with the `toStructure` syntax.

Right now I have…

```php
<?php foreach($page->builder()->toStructure() as $section): ?>
  <li><!-- stuff goes here --></li>
<?php endforeach ?>

```

Which is looping through a bunch of content blocks and displaying content as appropriate. Works as expected _except_ that I’d like this to be reversed, since every new builder block gets added to the end and ideally those newest blocks would get listed at the top. I tried `$page->builder()->toStructure()->reverse()` but that didn’t work. I _was_ able to find success with `$page->builder()->toStructure()->sortBy('subdate', 'desc')`, which works great, except unfortunately in this case `subdate` is an optional field, so sorting by that date isn’t always going to work.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 4, 2015, 7:27pm UTC](https://forum.getkirby.com/t/tostructure-reverse/1765/2 "2015-08-04T19:27:04Z")

</div>

The following should work:

```php
$page->builder()->toStructure()->flip();

```

---

<div class="post-metadata">

**Author:** ![AhoyLemon](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahoylemon/32/4762_2.png) [@AhoyLemon](https://forum.getkirby.com/u/AhoyLemon)\
**Post date:** [August 4, 2015, 7:38pm UTC](https://forum.getkirby.com/t/tostructure-reverse/1765/3 "2015-08-04T19:38:58Z")

</div>

100%. Thanks, @lukasbestle

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:16pm UTC](https://forum.getkirby.com/t/tostructure-reverse/1765/4 "2025-02-06T17:16:56Z")

</div>


