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; }