sebastienros / jint

Javascript Interpreter for .NET
BSD 2-Clause "Simplified" License
4.04k stars 558 forks source link

LocaleCompare encountered inconsistent results with the browser #1852

Closed hvppy closed 4 months ago

hvppy commented 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

lahma commented 4 months ago

A pull request with a fix would be appreciated. I cannot read or comprehend those characters.