Correct outdated info

As of the last versions of V8 (i.e. Chrome and Node.js), the current info seems outdated.

See also https://v8.dev/blog/array-sort
This commit is contained in:
Vse Mozhe Buty 2020-10-09 17:47:25 +03:00 committed by GitHub
parent bdb3def468
commit b2b83b7472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -419,7 +419,7 @@ Now it works as intended.
Let's step aside and think what's happening. The `arr` can be array of anything, right? It may contain numbers or strings or objects or whatever. We have a set of *some items*. To sort it, we need an *ordering function* that knows how to compare its elements. The default is a string order.
The `arr.sort(fn)` method implements a generic sorting algorithm. We don't need to care how it internally works (an optimized [quicksort](https://en.wikipedia.org/wiki/Quicksort) most of the time). It will walk the array, compare its elements using the provided function and reorder them, all we need is to provide the `fn` which does the comparison.
The `arr.sort(fn)` method implements a generic sorting algorithm. We don't need to care how it internally works (an optimized [quicksort](https://en.wikipedia.org/wiki/Quicksort) or [Timsort](https://en.wikipedia.org/wiki/Timsort) most of the time). It will walk the array, compare its elements using the provided function and reorder them, all we need is to provide the `fn` which does the comparison.
By the way, if we ever want to know which elements are compared -- nothing prevents from alerting them: