Extract (refactor) sort determination code into helper functions. Also stop sorting finished tasks to the end of the list.
Only show priority and category headers when the list is sorted by priority since the headers don't structure the list well with other sorts and collapsing the headers doesn't work fully with other sorts