一个新的知识点:关于排序的问题。
如何对于sort排序的理解。
https://blog.csdn.net/weimob258616/article/details/89737057
这里sort调用了 compareFunction
sort(function(a,b){
if(a>b){
return 1;
}
if(a<b){
return -1;
}
return 0;
}
)
如果是a>b返回的就是b,a。
这种排序,如果是按照丛大到小排序,是b-a,
people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]
people.sort((a, b) => a[0] === b[0] ? a[1] - b[1] : b[0] - a[0])