Bug 187134
| Summary: | Inconsistent output compared with other JS engines when using sort() | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | sunlili |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | Normal | CC: | ggaren, ysuzuki |
| Priority: | P2 | ||
| Version: | WebKit Local Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
sunlili
Hello,
The following code behaves strangely (inconsistent with other engines).
a=[3.3,2.2,1];
a.sort(function () { return -1;});
In Safari, output is
[1, 2.2, 3.3]
However, output should be:
[3.3, 2.2, 1]
BT group
2018.6.28
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Yusuke Suzuki
I think this is OK. This relies on how comparator is called (since it does not produce consistent results, comp(a, b) => -1 comp(b, a) => -1), and it is implementation dependent according to the spec.