From 876c81f710711ba2afb36dd83889d4c5b4fc2743 Mon Sep 17 00:00:00 2001 From: Gijs Date: Tue, 20 Nov 2018 09:11:00 +0000 Subject: [PATCH] Update sorting function in Readability.js Simplify sorting function also considering case where arguments are equal Co-Authored-By: jemrobinson --- Readability.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readability.js b/Readability.js index b62f41a..859bcb5 100644 --- a/Readability.js +++ b/Readability.js @@ -1141,7 +1141,7 @@ Readability.prototype = { this._attempts.push({articleContent: articleContent, textLength: textLength}); // No luck after removing flags, just return the longest text we found during the different loops this._attempts.sort(function (a, b) { - return (a.textLength < b.textLength) ? 1 : -1; + return b.textLength - a.textLength; }); // But first check if we actually have something