fix sort and order remaining undefined on page load