I’m working on some structure with @timoetting’s terrific builder plugin, and I hit a little wall with the toStructure syntax.

Right now I have…

<?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.

The following should work:


100%. Thanks, @lukasbestle