Added sort checkboxes, implemented sort function in model