Using Vue.js to calculate percentages, consider the following code snippet:
<tr>
<span v-for="(item, index) in data.values" :key="index" >
{{ item.name }} {{ getPercentage(item.nr) }}
</span>
</tr>
Here's the method to calculate percentage:
methods: {
getPercentage (number) {
return number / this.nrUsers * 100; // Ignore the logic for now
}
}
The calculation of percentage values is correct, but the issue arises when displaying them. Sorting in descending order is desired, and since the calculation happens here, backend sorting seems challenging. Any suggestions on how to achieve descending sorting in Vue.js?