Sort before trimming the list back to @maximum_tasks.