Skip to content

Commit 876c81f

Browse files
gijskjemrobinson
andcommitted
Update sorting function in Readability.js
Simplify sorting function also considering case where arguments are equal Co-Authored-By: jemrobinson <james.em.robinson@gmail.com>
1 parent ee18c21 commit 876c81f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Readability.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ Readability.prototype = {
11411141
this._attempts.push({articleContent: articleContent, textLength: textLength});
11421142
// No luck after removing flags, just return the longest text we found during the different loops
11431143
this._attempts.sort(function (a, b) {
1144-
return (a.textLength < b.textLength) ? 1 : -1;
1144+
return b.textLength - a.textLength;
11451145
});
11461146

11471147
// But first check if we actually have something

0 commit comments

Comments
 (0)