var task = [ {name:"aa", taskLevel:"3",createTime:"2019-12-18"}, {name:"bb", taskLevel:"2", createTime:"2019-12-12"}, {name:"cc", taskLevel:"2",createTime:"2019-12-13"} ]; task.sort(function(a,b){
if(a.taskLevel === b.taskLevel){
return new Date(a.createTime).getTime() - new Date(b.createTime).getTime();
} return a.taskLevel - b.taskLevel; }); console.log(task);
试题任务排序,先根据任务紧急度,相同紧急度根据任务创建时间
来源:https://blog.csdn.net/u013654125/article/details/81874480