> Most languages’ baseline sort operations implement quicksort under the hood, including the standard C library’s gsort() and JavaScript’s Array.prototype.sort()<p>There isn't any "JavaScript's Array.prototype.sort()". Different implementations use different algorithms.<p>I know V8 used to use Quicksort with insertion sort for (sub)arrays smaller than 10 elements (the implementaion has changed since I last looked, but I don't know what).<p>But SpiderMonkey has and still does use a bottom up mergesort with insertion sort for subarrays of length 3.
> <i>Quicksort is a mouthful to explain in detail</i><p>Don't know about that, this is not efficent but "explains" quicksort in general:<p><pre><code> fun <T : Comparable<T>> quickSort(list: List<T>): List<T> =
with(list) {
if (size < 2) this
else {
val pivot = first()
val (smaller, greater) = drop(1).partition { it <= pivot }
quickSort(smaller) + pivot + quickSort(greater)
}
}</code></pre>
Is it just me, shoe-horning this in there, or does this picture [1] of the Quicksort remind anyone else of a Scutoid? [2]<p>[1] <a href="https://dotink.co/img/quick-color.png" rel="nofollow">https://dotink.co/img/quick-color.png</a><p>[2] <a href="https://en.wikipedia.org/wiki/Scutoid" rel="nofollow">https://en.wikipedia.org/wiki/Scutoid</a>