I am looking to have a dropdown v-autocomplete to return the filtered results in reverse. For example the items in the dropdown would be [2.10, 2.9, 1.11, 1.10, 1.9, 1.6, 1.1]. When a user types 1.1 for example I would need the results to return in reverse (ascending order) such as [1.1, 1.10, 1.11] instead of the descending order.
Here is what I tried:
<v-autocomplete
v-model="searchText"
:items="items"
label="search"
:search-input.sync="filter"
ref="selectExample"
>
</v-autocomplete>
Then the script part is:
export default {
data() {
return {
searchText: '',
filter: '',
watch: {
filter() {
this.filteredItems = this.$refs['selectExample'].filteredItems.reverse()
},
}
}
}
}
Unfortunately this only reverses the order of items on the dropdown and doesn't reverse the order of the searched items. I have tried using filter as well but the filtered results just can't be modified it seems. Also when the search is cleared it should reset and show all the items again as before in descending order. Any help is appreciated thanks!