[Vuejs]-Sorting table in vue js

0👍

In terms of the sort function it depends which way you want to sort it.

If a is less than b and you want them to be in that order in the list then output -1 not 1

see this example

this.campaign.spend.sort((a, b) => {
    if (a.rating === b.rating)  return 0
    if (a.rating < b.rating) return -1
    if (a.rating > b.rating) return 1
})

Leave a comment