I have a function that sorts user profile card by name, the problem is that it only switches the name but keeps the data of the other user in the card.
For example I had Max first with location Niagara and then Joe with location Melbourne, when I sort it put Joe first but with Niagara instead of Melbourne
<select name="sort" @change="sortArray" v-model="filter">
<script>
props: { filter: '', selected:'name'},
data () {
return {
arrays: this.$store.state.arrays,
}}
methods:{
sortArray: function() {if(this.filter === 'name')
this.arrays.sort((a, b) => {return a.name < b.name ? -1 : 1})
//this.componentKey += 1 //for data refresh
}
}
</script>
I did a data refresh and that put the correct data but I’m looking for a way to correctly sort without having to refresh the data.
Thanks so much!