self.sortDeadlineFwdLive = function () {
self.deadline_fwd_lives.sort(function (left, right) {
if (left.penalty_due_date() || right.penalty_due_date()) {
if (left.penalty_due_date() == right.penalty_due_date()) {
return left.returned_date() == right.returned_date() ? 0 : ((left.returned_date() && left.returned_date() < right.returned_date()) || !right.returned_date() ? -1 : 1);
}
return left.fl_due_date() == right.fl_due_date() ? 0 : ((left.fl_due_date() && left.fl_due_date() < right.fl_due_date()) || !right.fl_due_date() ? -1 : 1);
}
return left.penalty_due_date() == right.penalty_due_date() ? 0 : ((left.penalty_due_date() && left.penalty_due_date() < right.penalty_due_date()) || !right.penalty_due_date() ? -1 : 1);
} else if (left.fl_due_date() == right.fl_due_date()) {
if (left.penalty_due_date() != right.penalty_due_date()) {
return left.returned_date() == right.returned_date() ? 0 : ((left.returned_date() && left.returned_date() < right.returned_date()) || !right.returned_date() ? -1 : 1);
}
return left.fl_due_date() == right.fl_due_date() ? 0 : ((left.fl_due_date() && left.fl_due_date() < right.fl_due_date()) || !right.fl_due_date() ? -1 : 1);
} else {
return left.returned_date() == right.returned_date() ? 0 : ((left.returned_date() && left.returned_date() < right.returned_date()) || !right.returned_date() ? -1 : 1);
}
});
};
上面是我的js函数的代码,但是我不能正确,已经尝试了几个小时,仍然无法弄清楚,我对js很可怕,任何善良的灵魂都可以解决它,也许只是语法错误
答案 0 :(得分:3)
您错过了if
之前的起始if (left.penalty_due_date() || right.penalty_due_date()) {
条款。
答案 1 :(得分:3)
错误在这一行:
} else if (left.fl_due_date() == right.fl_due_date()) {
}
正在关闭一个函数,而不是if。