diff --git a/static/js/util.js b/static/js/util.js index 0644cefbfb..0b83fc2d60 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -241,10 +241,10 @@ exports.prefix_sort = function (query, objs, get_item) { var beginswithCaseSensitive = []; var beginswithCaseInsensitive = []; var noMatch = []; - - var obj = objs.shift(); - while (obj) { - var item; + var obj; + var item; + for (var i = 0; i < objs.length; i += 1) { + obj = objs[i]; if (get_item) { item = get_item(obj); } else { @@ -257,7 +257,6 @@ exports.prefix_sort = function (query, objs, get_item) { } else { noMatch.push(obj); } - obj = objs.shift(); } return { matches: beginswithCaseSensitive.concat(beginswithCaseInsensitive), rest: noMatch };