Home > Net >  How can I sorting this arrays?
How can I sorting this arrays?

Time:03-16

You can see in below image that array numbers are not sorting. How can I fix it ? I'm using Vue.js

enter image description here

Code :

 created() {
   if (this.InputMain.HarmonicSpecials.length == 0) {
     for(var i = 1;i <= 33; i= i   2) {
       this.InputMain.HarmonicSpecials.Order.sort(function(a, b) { 
         return b - a
       });
       this.InputMain.HarmonicSpecials.push({Order:i,Value:0});
    }
  }
}

CodePudding user response:

I fixed it. Thank you All!

else (this.InputMain.HarmonicSpecials.length!==0)
{
  this.InputMain.HarmonicSpecials.sort(function(a, b){return a.Order - b.Order});

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>

  • Related