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:
parent
bdb3def468
commit
f880f1fb63
1 changed files with 1 additions and 0 deletions
|
@ -426,6 +426,7 @@ By the way, if we ever want to know which elements are compared -- nothing preve
|
||||||
```js run
|
```js run
|
||||||
[1, -2, 15, 2, 0, 8].sort(function(a, b) {
|
[1, -2, 15, 2, 0, 8].sort(function(a, b) {
|
||||||
alert( a + " <> " + b );
|
alert( a + " <> " + b );
|
||||||
|
return a - b;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue