Sorting pages as in the panel view

I don’t get why this bits of code isn’t working here.

       <?php $index = 0;
            foreach ($site->find("commandes")->children()->listed()->template('photos')->sortBy('modified', 'asc') as $page) : $index++;
                $next = $index + 1; ?>
                <a data-template="<?= $page->intendedTemplate() ?>" data-step="<?php echo $index ?>" class="list-item" id="<?= $page->title() ?>"> <?= $page->title() ?>,</a>
            <?php endforeach ?>

This should sortBy the pages as they are in the panel, right?

Thanks.

No, why? This sorts by last modification date. I don’t know how you sort your pages in the Panel.

On a side note, I wouldn’t use $page in your loop, because $page is a reserved template variable, use some other variable name.

Oh, well thanks then, haha.
Is there a way to display the page in the same order as they are in the panel view?

Thanks.
Noted for page, you are right, will change that.

I repeat:

Well, they are manually arranged. Just organised by how the user like them to be…
But on the website, they are displayed sorted alphabetically, that’s not really what I’m looking for, I’d like to keep the user order.

If they use the default numbering scheme for manual sorting, then not sorting them at all should display them in the right order, from 1 to x. To reverse, use flip().