the sortOptions gets the value but the function doesnt work (composition api) im trying to sort by price
const sortOptions = ref([
{ name: "Now Trending", value: "all" },
{ name: "Price (Low - High)", value: "asc" },
{ name: "Price (High - Low)", value: "desc" }
])
const sortBy = () => {
products.value.sort((a, b) => {
let ascending = a.price - b.price;
let descending = b.price - a.price;
sortOptions.value.filter((item) => {
if(item.value === 'all') return;
if(item.value === 'asc') return ascending;
if(item.value === 'desc') return descending;
})
})
}
<select name="sortBy" id="sortBy" @change.prevent="sortBy">
<option v-for="(option, index) in sortOptions" :value="option.value"
:key="index">
{{ option.name }}
</option>
</select>
