Skip to main content

Module sort

Module sort 

Source
Expand description

Array.prototype.sort as V8 implements it.

Some comparators the client ports are not consistent (the AST condition comparator orders subqueries before conjunctions from both sides), so the result depends on the exact sequence of comparisons. V8’s TimSort, for arrays shorter than its minimum run of 64, finds the leading run (reversing it if strictly descending) and binary-insertion-sorts the rest; that is reproduced here exactly. Longer arrays use the same insertion sort, which matches V8 for consistent comparators (it is stable).

Functions§

sort