Closed Bug 331148 Opened 19 years ago Closed 19 years ago

Javascript sort sometimes changes order of array items when they are equivalent

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 224128

People

(Reporter: dmceo415, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 From http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:sort : "If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements." This behavior occurs in IE and Opera, but not Firefox. When using array.sort(compareFunction) and function compareFunction(a, b) { return a - b; }, Firefox will often reverse the order of a and b relative to each other when a-b=0. Reproducible: Always
Duplicate of Core bug 321803 -> Core bug 224128?
*** This bug has been marked as a duplicate of 224128 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.