在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ javacript的sort不加函數(shù)的時(shí)候是將數(shù)組里面的每個(gè)item轉(zhuǎn)換為字符串

javacript的sort不加函數(shù)的時(shí)候是將數(shù)組里面的每個(gè)item轉(zhuǎn)換為字符串,然后比較每個(gè)子字符串第一個(gè)字符的ASCII嗎?

const numArr = [2, 4, 8, 609545, 2, 8, 4, 1, 10, 123, 99];
const strArr = ["what", "We", "have", "lost", "will", "never"];
console.log(strArr.sort());
console.log(numArr.sort());

clipboard.png

回答
編輯回答
拼未來
The sort() method sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is according to string Unicode code points.

是Unicode,別的語言也需要排序。

Array.prototype.sort()

2017年7月14日 16:54
編輯回答
尤禮

根據(jù)Unicode排序的

strArr = strArr.sort((a,b)=>a-b);
2018年4月19日 15:51