Make code example more realistic and safe

1. Without a real sorting part, the data output is not the same as with real sort (as the array is not really sorted when the callback returns `undefined`).
2. Current example may somehow encourage a reader to write sorting callbacks with undetermined behavior.
This commit is contained in:
Vse Mozhe Buty 2020-10-09 17:42:08 +03:00 committed by GitHub
parent bdb3def468
commit f880f1fb63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -426,6 +426,7 @@ By the way, if we ever want to know which elements are compared -- nothing preve
```js run
[1, -2, 15, 2, 0, 8].sort(function(a, b) {
alert( a + " <> " + b );
return a - b;
});
```