-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
⚙ Compilation target
esnext
⚙ Library
5.7.2
Missing / Incorrect Definition
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
- * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
+ * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
Sample Code
// N/A (issue relates to JSDoc/intellisense)
Documentation Link
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
The
sort()
method of Array instances sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code unit values.
https://tc39.es/ecma262/multipage/indexed-collections.html#sec-comparearrayelements
- Let xSmaller be ! IsLessThan(xString, yString, true).
- If xSmaller is true, return -1𝔽.
? 9. Let ySmaller be ! IsLessThan(yString, xString, true).- If ySmaller is true, return 1𝔽.
https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islessthan
- If px is a String and py is a String, then
a. Let lx be the length of px.
b. Let ly be the length of py.
c. For each integer i such that 0 ≤ i < min(lx, ly), in ascending order, do
i. Let cx be the numeric value of the code unit at index i within px.
ii. Let cy be the numeric value of the code unit at index i within py.
iii. If cx < cy, return true.
iv. If cx > cy, return false.
d. If lx < ly, return true. Otherwise, return false.
(Emphasis added)
Metadata
Metadata
Assignees
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases