[Webkit-unassigned] [Bug 95309] Sorting array with objects using a custom function returns strange result if array length > 10
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Aug 29 10:58:16 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=95309
Oliver Hunt <oliver at apple.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Oliver Hunt <oliver at apple.com> 2012-08-29 10:58:19 PST ---
Your comparison function is bogus.
You return (in essence) a < b.
Which is a bool, so converts to 0 or 1 (false, true)
Per spec, a result of 0 means that the two values are the same, so if we end do compare(3,1) we will get a result of 0 (3 and 1 are the same value for the purposes of sorting) but if we do compare(1,3) we will get a result of 1 (1 is greater than 3, for the purpose of sorting).
Hence the results are inconsistent and we can't guarantee anything sensible will come out the other end.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list