Add alphabetical secondary sort when bringing prefix matches to the top

This commit is contained in:
dloverin committed 2013-03-29 14:50:52 -04:00
1 parent d947130020
commit bf7404aa6d
1 file changed
+3 -1
@@ -162,6 +162,8 @@ define(function (require, exports, module) {
*/
function formatHints(hints, query) {
if (query.length > QUERY_PREFIX_LENGTH) {
// raise the hints that match on prefix to the top of the list.
hints.sort(function (hint1, hint2) {
var index1 = hint1.value.toLowerCase().indexOf(query.toLowerCase()),
index2 = hint2.value.toLowerCase().indexOf(query.toLowerCase());
@@ -171,7 +173,7 @@ define(function (require, exports, module) {
} else if (index1 !== 0 && index2 === 0) {
return 1;
}
return compareByName(hint1, hint2);
});
}