var lastControllerLocation = "#index!1"; controllers.index = function(search, sort, sortDirection) { var _this = this; function sortFor(type) { if(!type) type = "publishedOn"; if(type == "publishedOn") return function(story) { return story.publishedOn; }; if(type == "wordCount") return function(story) { return story.wordCount; }; } var storys = store; if(search && search != "") { regex = RegExp(search, "i"); storys = _.filter(storys, function(story) { return story.title.match(regex); }); } storys = _.sortBy(storys, sortFor(sort)); if(!sortDirection) sortDirection = "desc"; if(sortDirection == "desc") storys = storys.reverse(); storys = _.first(storys, 500); function addStorys(storys) { if($("#stories > li").length) return; _.each(storys, function(story) { var item = $("