Pagination not honouring post date

So I have next/prev links below my blog posts that (obviously) go to the next/previous post that was published. However, they’re not honouring the published() date. Instead, it seems to be honouring the modified date.

So, when I get to my “Hello World” post, which was the first post I published and therefore the last post in the list, I still see an option to go to the “next post” which “Post Number 2” as that was modified after “Hello World”.

I do have a date field, which is called published. Here’s my code:

<div class="post-nav single">
                <div>
                    <?php if ($prev = $page->prevListed()): ?>
                    <p>← The one before<br>
                    <a href="<?= $prev->url() ?>"><?= $prev->title() ?></a></p>
                    <?php endif ?>
                </div>
                <div class="post-nav-next">
                    <?php if ($next = $page->nextListed()): ?>
                    <p> Up next →<br>
                    <a href="<?= $next->url() ?>"><?= $next->title() ?></a></p>
                    <?php endif ?>
                </div>
            </div>

See Previous / Next navigation becomes random navigation - #5 by GB_DESIGN

Already figured it out - sorry, should have played more before posting. Here’s my working code if it’s useful to anyone else. I didn’t actually sort the posts before adding the pagination. :man_facepalming:

<div class="post-nav single">
                <div>
                    <?php $entries = $page->siblings()->listed()->sortBy(function ($page) {return $page->published()->toDate();}, 'asc');
                    if ($page->hasPrevListed($entries)): ?>
                    <p>← The one before<br>
                    <a href="<?= $page->prevListed($entries)->url() ?>"><?= $page->prevListed($entries)->title() ?></a></p>
                    <?php endif ?>
                </div>
                <div class="post-nav-next">
                    <?php if ($page->hasNextListed($entries)): ?>
                    <p> Up next →<br>
                    <a href="<?= $page->NextListed($entries)->url() ?>"><?= $page->NextListed($entries)->title() ?></a></p>
                    <?php endif ?>
                </div>
            </div>