Summary: | Javascript numeric array.sort() returns a bad result if one or more elements vary greatly | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jim Perry <james.r.perry> | ||||
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | RESOLVED INVALID | ||||||
Severity: | Normal | CC: | ggaren | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Mac (Intel) | ||||||
OS: | OS X 10.5 | ||||||
Attachments: |
|
Description
Jim Perry
2009-07-28 14:32:15 PDT
Can you attach a test case as an attachment to the bug? It's hard to follow in the comment like it is. Created attachment 33675 [details]
Test case for numeric array.sort() bad results
Array.prototype.sort defaults to string sort, not numeric sort. Your title says "numeric". Why did you expect this sort to be numeric? (In reply to comment #3) > Array.prototype.sort defaults to string sort, not numeric sort. Your title says > "numeric". Why did you expect this sort to be numeric? I was expecting a numeric sort since I was not giving it string literals. Having looked at the Javascript core reference, I see that I am incorrect and this is not a bug. > I was expecting a numeric sort since I was not giving it string literals.
> Having looked at the Javascript core reference, I see that I am incorrect and
> this is not a bug.
Yeah, this is a bit of a gotcha in JavaScript. :(
|