js two field attribute sorted array

var Task = [ 
        {name: "AA", taskLevel: ". 3", createTime: "99" }, 
        {name: "BB", taskLevel: "2", createTime: "100" }, 
        {name: "CC" , taskLevel: "2", createTime: "99" } 
    ]; 
        
    task.sort ( function (A, B) {
         IF (a.taskLevel === b.taskLevel) {
             return a.createTime - b.createTime; 
        } 
        return a.taskLevel - b.taskLevel; 
    }); 
     
    the console.log (task); 
questions sorting task, the first task in accordance with the degree of urgency, the same degree of urgency of any
creation time tasks

source:https://blog.csdn.net/u013654125/article/details/81874480

Guess you like

Origin www.cnblogs.com/chuanq/p/11904674.html