📜  排序函数解释javascript代码示例

📅  最后修改于: 2022-03-11 15:03:43.630000             🧑  作者: Mango

代码示例2
var sortedArray = myArray.sort(function(a,b){
                                   if (a.name < b.name)
                                      return -1;
                                   else if (a.name == b.name)
                                      return 0;
                                   else
                                      return 1;
                               });