From e6e56ef97e4a0e5e657aafaa769be107bec40dc3 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 16 Jul 2013 16:47:03 -0400 Subject: [PATCH] search.js: sort earlier when building typeahead objects This sets up a later optimization. (imported from commit 49d285ce4e30fff222c8160d12fd345b9afeb417) --- zephyr/static/js/search.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zephyr/static/js/search.js b/zephyr/static/js/search.js index f37cb334db..4ca041d32f 100644 --- a/zephyr/static/js/search.js +++ b/zephyr/static/js/search.js @@ -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; }