I want to sort my array by date and count, i'm able to sort array only by date my data is as below
count date
"0" "2018-03-06T07:09:02+00:00"
"0" "2018-03-06T07:07:02+00:00"
"0" "2018-03-06T07:06:03+00:00"
"0" "2018-03-06T07:02:06+00:00"
"0" "2018-03-06T06:39:55+00:00"
"0" "2018-03-06T06:30:14+00:00"
"1" "2018-03-06T06:22:20+00:00"
"1" "2018-03-06T06:07:04+00:00"
"0" "2018-03-06T06:03:17+00:00"
"14" "2018-03-01T10:28:27.998000+00:00"
"0" null
"0" null
"0" null
my code is below..
this.nodelist.sort((a, b) => {//lastDate dsc
if (new Date(b.lastDate) > new Date(a.lastDate)) {
return 1;
}
if (new Date(b.lastDate) < new Date(a.lastDate)) {
return -1;
}
return 0;
});
i want to sort array by count and date both means if array is having count > 0 then it should be first then count with zero and on last all other records. can anyone help me to solve this?