added sort function for priority, date and title