Closed hvppy closed 4 months ago
var json={ 王五:3,赵六:4,张三:1,李四:2, }
return Object.keys(json).sort(function(a,b){ return a.localeCompare(b); }); //Browser Results ['李四', '王五', '张三', '赵六'] //jint Results ['张三', '李四', '王五', '赵六']
return Object.keys(json).sort(); //Browser Results ['张三', '李四', '王五', '赵六'] //jint Results ['张三', '李四', '王五', '赵六']
There is inconsistency in the comparison method of localeCompare, and I don't know how to solve it
A pull request with a fix would be appreciated. I cannot read or comprehend those characters.
var json={ 王五:3,赵六:4,张三:1,李四:2, }
return Object.keys(json).sort(function(a,b){ return a.localeCompare(b); }); //Browser Results ['李四', '王五', '张三', '赵六'] //jint Results ['张三', '李四', '王五', '赵六']
return Object.keys(json).sort(); //Browser Results ['张三', '李四', '王五', '赵六'] //jint Results ['张三', '李四', '王五', '赵六']
There is inconsistency in the comparison method of localeCompare, and I don't know how to solve it