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

RESOLVED DUPLICATE of bug 224128

Status

()

Firefox
General
--
major
RESOLVED DUPLICATE of bug 224128
12 years ago
12 years ago

People

(Reporter: dmceo415, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
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

Comment 1

12 years ago
Duplicate of Core bug 321803 -> Core bug 224128?

*** This bug has been marked as a duplicate of 224128 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.