Hi Everyone,
I try to sort events by date, but in the opposite order. for example, right now it shows the events from the earliest to the latest:
- may 1st
- june 20th
- july 19th
I want it to appear in a reverse order:
- july 19th
- june 20th
- may 1st
this is my code:
<?php
$events = page()->children()->listed();
$sortedEvents = $events->sortBy(function ($page) {
return $page->starts()->toDate();
});
foreach($sortedEvents as $event): ?>
<div class='event'>
<div class='event-dates'>
<p><?= $event->starts()->toDate('d F') ?></p>
</div>
</div>
<?php endforeach ?>
I noticed that there is the flip() method but Im not sure where to use it.
Thanks in advance!