Skip to content

Commit b9d0c67

Browse files
committed
shorter name breaks ties
1 parent e607947 commit b9d0c67

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/resources/script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ function initSearch() {
110110
});
111111

112112
allMatches.sort(function(a, b) {
113-
return b.score - a.score;
113+
var x = b.score - a.score;
114+
if (x === 0) {
115+
// tie-breaker: shorter name wins
116+
return a.e.name.length - b.e.name.length;
117+
} else {
118+
return x;
119+
}
114120
});
115121

116122
var sortedMatches = [];

0 commit comments

Comments
 (0)