From f880f1fb631922782efed00b4bfe2188d749d3aa Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Fri, 9 Oct 2020 17:42:08 +0300 Subject: [PATCH] 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-js/05-data-types/05-array-methods/article.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index 3afba386..edd9ddee 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -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; }); ```