Skip to content

Commit ded1a6a

Browse files
vsemozhetbytViolet-Bora-Lee
authored andcommitted
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.
1 parent 0fadb7f commit ded1a6a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

1-js/05-data-types/05-array-methods/article.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ alert(arr); // *!*1, 2, 15*/!*
427427
```js run
428428
[1, -2, 15, 2, 0, 8].sort(function(a, b) {
429429
alert( a + " <> " + b );
430+
return a - b;
430431
});
431432
```
432433

0 commit comments

Comments
 (0)