When javacript's sort does not add a function, does it convert each item in the array into a string, and then compare the ASCII of the first character of each substring?

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

Mar.05,2021

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.

is Unicode,. Other languages also need sorting.

Array.prototype.sort ()


sorted by Unicode

strArr = strArr.sort((a,b)=>a-b);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31782-2bd7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31782-2bd7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?