Code to Use Dropdown to Sort

And if you need to change the direction of the sort, just add another parameter and an object literal with the directions choices and when calling sortData , add the direction as a string, like so:

const sortData = (sorting, direction) => {
  const sortingDirection = {
    asc: wixData.sort().ascending(sorting),
    desc: wixData.sort().descending(sorting),
  }
  $w('#dynamicDataset').setSort(sortingDirection[direction])
}

$w.onReady(() => {
  $w('#dropdown').onChange((e) => sortData($w('#dropdown').value), 'desc') // Like this
})