Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 884595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:46:28+00:00 2026-05-15T12:46:28+00:00

I know that the ECMA Script specification does not specify which algorithm to use

  • 0

I know that the ECMA Script specification does not specify which algorithm to use for sorting arrays, nor does it specify whether the sort should be stable.

I’ve found this information for Firefox which specifies that firefox uses a stable sort.

Does anyone know about IE 6/7/8, Chrome and Safari?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:46:28+00:00Added an answer on May 15, 2026 at 12:46 pm

    As of ES2019, sort is required to be stable. In ECMAScript 1st edition through ES2018, it was allowed to be unstable.

    Simple test case (ignore the heading, second set of numbers should be sequential if the engine’s sort is stable). Note: This test case doesn’t work for some versions of Chrome (technically, of V8) that switched sorting algorithms based on the size of the array, using a stable sort for small arrays but an unstable one for larger arrays. (Details.) See the end of the question for a modified version that makes the array large enough to trigger the behavior.

    IE’s sort has been stable as long as I’ve ever used it (so IE6). Checking again in IE8 and it appears to still be the case.

    And although that Mozilla page you link to says Firefox’s sort is stable, I definitely say this was not always the case prior to (and including) Firefox 2.0.

    Some cursory results:

    • IE6+: stable
    • Firefox < 3: unstable
    • Firefox >= 3: stable
    • Chrome < 70: unstable
    • Chrome >= 70: stable
    • Opera < 10: unstable
    • Opera >= 10: stable
    • Safari 4: stable
    • Edge: unstable for long arrays (>512 elements)

    All tests on Windows.

    See also: Fast stable sorting algorithm implementation in javascript

    This test case (modified from here) will demonstrate the problem in V8 (for instance, Node v6, Chrome < v70) by ensuring the array has enough entries to pick the “more efficient” sort method; this is written with very old JavaScript engines in mind, so without modern features:

    function Pair(_x, _y) {
        this.x = _x;
        this.y = _y;
    }
    function pairSort(a, b) {
        return a.x - b.x;
    }
    var y = 0;
    var check = [];
    while (check.length < 100) {
        check.push(new Pair(Math.floor(Math.random() * 3) + 1, ++y));
    }
    check.sort(pairSort);
    var min = {};
    var issues = 0;
    for (var i = 0; i < check.length; ++i) {
        var entry = check[i];
        var found = min[entry.x];
        if (found) {
            if (found.y > entry.y) {
                console.log("Unstable at " + found.i + ": " + found.y + " > " + entry.y);
                ++issues;
            }
        } else {
            min[entry.x] = {x: entry.x, y: entry.y, i: i};
        }
    }
    if (!issues) {
        console.log("Sort appears to be stable");
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 437k
  • Answers 437k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use NSTimer. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { timer = [NSTimer scheduledTimerWithTimeInterval:0.25… May 15, 2026 at 4:09 pm
  • Editorial Team
    Editorial Team added an answer That suspiciously looks like a csv-file. You could try using… May 15, 2026 at 4:09 pm
  • Editorial Team
    Editorial Team added an answer You should not declare a variable in a switch case… May 15, 2026 at 4:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.