[Webkit-unassigned] [Bug 27781] New: Javascript numeric array.sort() returns a bad result if one or more elements vary greatly
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Jul 28 14:32:16 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=27781
Summary: Javascript numeric array.sort() returns a bad result
if one or more elements vary greatly
Product: WebKit
Version: 528+ (Nightly build)
Platform: Macintosh Intel
OS/Version: Mac OS X 10.5
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: james.r.perry at gmail.com
Here is the code and the results:
var cols = [100,200,300,400]; alert('1a: '+cols); cols.sort();
alert('1b: '+cols); cols.reverse(); alert('1c: '+cols);
// Displays: "1a: 100,200,300,400", "1b: 100,200,300,400", "1c:
400,300,200,100"
var cols = [400,300,200,100]; alert('2a: '+cols); cols.sort();
alert('2b: '+cols); cols.reverse(); alert('2c: '+cols);
// Displays: "2a: 400,300,200,100", "2b: 100,200,300,400", "2c:
400,300,200,100"
var cols = [888,666,999,777]; alert('3a: '+cols); cols.sort();
alert('3b: '+cols); cols.reverse(); alert('3c: '+cols);
// Displays: "3a: 888,666,999,777", "3b: 666,777,888,999", "3c:
999,888,777,666"
var cols = [997,998,999,1000]; alert('4a: '+cols); cols.sort();
alert('4b: '+cols); cols.reverse(); alert('4c: '+cols);
// Displays: "4a: 997,998,999,1000", "4b: 1000,997,998,999", "4c:
999,998,997,1000"
var cols = [998,999,1000,1001]; alert('5a: '+cols); cols.sort();
alert('5b: '+cols); cols.reverse(); alert('5c: '+cols);
// Displays: "5a: 998,999,1000,1001", "5b: 1000,1001,998,999",
"5c: 999,998,1001,1000"
var cols = [1000,100,5000,10000,500]; alert('6a: '+cols);
cols.sort(); alert('6b: '+cols); cols.reverse(); alert('6c: '+cols);
// Displays: "6a: 1000,100,5000,10000,500", "6b:
100,1000,10000,500,5000", "6c: 5000,500,10000,1000,100"
var cols = [300,80,7777,25,500]; alert('7a: '+cols); cols.sort();
alert('7b: '+cols); cols.reverse(); alert('7c: '+cols);
// Displays: "7a: 300,80,7777,25,500", "7b: 25,300,500,7777,80",
"7c: 80,7777,500,300,25"
var cols = [12000,14000,11000,10000,13000]; alert('1a: '+cols);
cols.sort(); alert('1b: '+cols); cols.reverse(); alert('1c: '+cols);
// Displays: "1a: 12000,14000,11000,10000,13000", "1b:
10000,11000,12000,13000,14000", "1c: 14000,13000,12000,11000,10000"
var cols = [12000,14000,1100,10000,13000]; alert('1a: '+cols);
cols.sort(); alert('1b: '+cols); cols.reverse(); alert('1c: '+cols);
// Displays: "1a: 12000,14000,1100,10000,13000", "1b:
10000,1100,12000,13000,14000", "1c: 14000,13000,12000,1100,10000"
--
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