Loosing dataset data after query

Answering to myself…
The only way I found is to re-run the dataset query every time a “sort” button is clicked, with the sort in the query, instead of running only a dataset.setSort() :

export function button2_click(event) {  // sort on team
    $w('#dataset1').refresh();
    $w('#dataset1').onReady(() => {
 let dpd = $w('#dropdown1').value;
 if (dpd === '') {   // '#dropdown1' is empty if no season selected yet
           dpd = $w('#dropdown1').placeholder;}
 var lowerYear = dpd.substring(0,4);
 var upperYear = dpd.substring(5,9);
 var lowerDate = new Date(lowerYear.concat('-','9','-','1'));
 var upperDate = new Date(upperYear.concat('-','6','-','30'));
        wixData.query('match')
        .gt('dateHeure', lowerDate)
        .lt('dateHeure', upperDate)
        .ascending('equipe')
        .limit(300)
        .find()
        .then( (res) => {
 let tableRows = res.items;
           $w('#table1').rows = tableRows;
        })
    })
}