sortBy date asc - but date is into a structure

Hi
I would like to sortBy my subpages in the panel by date asc.
But the date is into a structure of many dates into the subpage and I want the first of the structure.

Here is the code of the blueprint /site/blueprints/pages/evenements.yml

sections:
  published:
    headline: Publié
    type: pages
    status: listed
    layout: cards
    template: evenement
    info: "{{ page.getfirstdate }}"
    sortBy: "{{ page.getfirstdate }}" desc

And here is the code of my “getfirstdate” function that I create into /site/models/evenement.php

    public function getfirstdate()
    {
        $structure = $this->content()->get('dates')->toStructure();
        $first = $structure->first();
        return $first->date()->toDate('d.m.Y');
    }

I got the first date of the structure but how to add the information of “asc” or “desc” into the sortBy of the blueprint ?

Thank you

I’m not sut but did you try following?

sortBy: getfirstdate desc
1 Like

Yes it works for me thank you !
Just the

->toDate('d.m.Y')

Should not be into the models but into the blueprint