Sort stability: Difference between revisions

Content added Content deleted
(Added AppleScript.)
Line 407: Line 407:


=={{header|JavaScript}}==
=={{header|JavaScript}}==
The ECMAScript 2019 standard defines Array.sort() as stable.
The ECMA standard does not specify what sorting algorithm to use, so it depends upon the implementation.

At the time of writing this is already implemented in in Node.js and in the JS interpreters of all major browsers, including Microsoft Edge, but not in the older Internet Explorer. In earlier interpreters, sort stability depends on particular implementations.


<lang javascript>ary = [["UK", "London"], ["US", "New York"], ["US", "Birmingham"], ["UK", "Birmingham"]]
<lang javascript>ary = [["UK", "London"], ["US", "New York"], ["US", "Birmingham"], ["UK", "Birmingham"]]