I have array obj like this:
[{ A: '24/12/2020', J: 54106, }, { A: '10/dd/2020', J: 54103 }, { A: 'mm/29/2020', J: 54103 }]
I wanna sort J field first then sort A field .. but I have issue when I sort, I wanna result like this :
[ { A: '10/dd/2020', J: 54103 }, { A: 'mm/29/2020', J: 54103 }, { A: '24/12/2020', J: 54106, }]
but data response is :
[{ A: 'mm/29/2020', J: 54103 }, { A: '10/dd/2020', J: 54103 }, { A: '24/12/2020', J: 54106, }]
My code here :
result.sort(function (a, b) {
return parseFloat(a.J) - parseFloat(b.J) || (a.A) - (b.A);
});
I think it need sort from number to text but it's not like that