且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按字母顺序对数组进行排序

更新时间:2023-01-30 15:20:20

是。如果您查看 MDN上的.sort() 方法指出省略了比较功能参数的情况:

Yes. If you look at the .sort() method on MDN it states the case when the compare function parameter is omitted:


指定一个定义排序顺序的函数。如果省略,则根据每个字符的Unicode代码点值和每个元素的字符串转换对数组进行排序。

Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element.

是ASCII的超集,是的,它的确按ASCII顺序排序。

Since Unicode is a super set of ASCII then yes it does sort in ASCII order.