Skip to content

Commit

Permalink
Update sorting function in Readability.js
Browse files Browse the repository at this point in the history
Simplify sorting function also considering case where arguments are equal

Co-Authored-By: jemrobinson <[email protected]>
  • Loading branch information
gijsk and jemrobinson committed Nov 20, 2018
1 parent ee18c21 commit 876c81f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 876c81f

Please sign in to comment.