Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSC] TypedArray sorting methods should have a special-case for compa…
…rator returning `false` https://bugs.webkit.org/show_bug.cgi?id=268075 <rdar://problem/122093956> Reviewed by Yusuke Suzuki and Justin Michaud. This change aligns TypedArray sorting methods with Array.prototype.sort() to treat `false`, returned from comparator function, like smallest negative number rather than zero, which is a long-time web reality quirk [1] to allow lexicographical comparison: `["c", "b", "a"].sort((a, b) => a > b)`. The spec [2] still lacks normative steps on how to handle comparator return value in the common case. This patch aligns JSC with V8 and SpiderMonkey. However, it appears that V8 have recently removed the special-case for `false` in Array sorting methods. [1]: https://bugs.webkit.org/show_bug.cgi?id=47825 [2]: https://tc39.es/ecma262/#sec-sortindexedproperties (step 4) * JSTests/stress/sorting-boolean-result-comparator-typedarray.js: Added. * Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::coerceComparatorResultToBoolean): (JSC::genericTypedArrayViewProtoFuncSortImpl): Canonical link: https://commits.webkit.org/276130@main
- Loading branch information