Minor fix to marking tasks after sorting.

Marking tasks will now sort tasks by position before marking.