diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/index.md index 934e1a068a..d96f2be573 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/index.md @@ -11,7 +11,7 @@ In the example given we see how to write a function which will return a new arra function reverseAlpha(arr) { return arr.sort(function(a, b) { - return a < b; + return a !== b ? a > b ? -1 : 1 : 0; }); } reverseAlpha(['l', 'h', 'z', 'b', 's']);