Closed
Description
All undefined elements are sorted to the end of the array, with no call to compareFunction.
Therefore, sorting on any type inhabited by undefined
will not use the correct ordering (except by coincidence). This is also a parametricity violation.
The only truthful use of native sort is on JavaScript values.
I propose we replace the implementation with a correct one. Yes, it will be slower. We might define unsafeSort
to use the native sort with the same typing as sort
. Then we may also have a different sort definition typed on JavaScript values (which is Foreign).
Metadata
Metadata
Assignees
Labels
No labels