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>
pull/504/head
Gijs 6 years ago
parent ee18c21fc2
commit 876c81f710

@ -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

Loading…
Cancel
Save