search.js: sort earlier when building typeahead objects

This sets up a later optimization.

(imported from commit 49d285ce4e30fff222c8160d12fd345b9afeb417)
This commit is contained in:
Steve Howell 2013-07-16 16:47:03 -04:00
parent f1da624353
commit e6e56ef97e

View File

@ -146,6 +146,8 @@ function get_stream_suggestions(query) {
return {action: 'stream', query: stream};
});
objs = typeahead_helper.sorter(query, objs, get_query);
$.each(objs, function (idx, obj) {
var prefix = 'Narrow to stream';
var stream = obj.query;
@ -154,8 +156,6 @@ function get_stream_suggestions(query) {
obj.search_string = get_search_string(obj);
});
objs = typeahead_helper.sorter(query, objs, get_query);
return objs;
}
@ -168,6 +168,11 @@ function get_person_suggestions(all_people, query, action) {
return {action: action, query: person};
});
objs.sort(function (x, y) {
return typeahead_helper.compare_by_pms(get_query(x), get_query(y));
});
$.each(objs, function (idx, obj) {
var prefix;
var person;
@ -187,11 +192,6 @@ function get_person_suggestions(all_people, query, action) {
obj.search_string = get_search_string(obj);
});
objs.sort(function (x, y) {
return typeahead_helper.compare_by_pms(get_query(x), get_query(y));
});
return objs;
}