[Vuejs]-How can I sort month by order?

0👍

Try this:

    computed : {
          sorted_orders_by_months() {
          var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
          return this.transaction_per_month.sort(function(a, b){
             return months.indexOf(a.Month) - months.indexOf(b.Month.);
      });
    }
 }

And then to represent it you can do something like:

v-for="(value, index) in sorted_orders_by_months"

Leave a comment