谷歌与火狐排序时,sort()返回-1时,前者会调换位置,后者不会。
谷歌:
const arr2 = [1,2,8, 5]
arr2.sort(function(a,b){
return a.matriCode > b.matriCode ? 1 : -1
})
结果 : [5, 8, 2, 1]
火狐:
const arr2 = [1,2,8, 5]
arr2.sort(function(a,b){
return a.matriCode > b.matriCode ? 1 : -1
})
结果: [ 1, 2, 8, 5 ]
谷歌:
火狐: ![](https://img-blog.csdnimg.cn/20210820161643401.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZhbmdnZV8=,size_16,color_FFFFFF,t_70)