I have a problem that a function keeps getting called before a loop finishes. How do I prevent the function from being called until after the loop finishes? My loop is outputting HTML tables to the page which is then being acted upon by my sortResultsByDate, but that can't happen until the HTML is rendered. Currently my second function is firing before the first one completes.
ns.executeUserSearch = function() {
    jQuery.each(searchInputArray, function(index, value) {
        ns.getUserSearchResults(searchInputArray, index);
    });
    ns.sortResultsByDate();
};
 
     
    