Sorting according to manual/folder numbering. Templating issue?

Hi all,

(Apologies if this question is a repeat and/or fairly simple! I’ve just been scratching my head for a while.)

I’m trying to sort the content under a folder called “photography” to sort according to the manual dragging in the CMS. The prefix of the folder names for each child are successfully getting renumbered according to the order in the CMS! :grinning: That’s why I think it’s a problem with how I’m templating it.

This is what I have to sort them. The result looks completely random.

<?php $i = 0; foreach(page('photography')->children()->sortBy('order', 'asc') as $upload): ?> 

Is there a better “sortBy” parameter that I could be using?

Happy to provide more info, and thank you all!!

There is actually no reason to sort them at all, unless you want to sort them in reverse order in which case you could just flip them:

$projects = page('photography')->children()->listed(); // standard order; only listed pages have numbers to sort by
$projects = page('photography')->children()->listed()->flip(); // reverse order

Thanks for the explanation! That did the trick! :smile: :pray: