Ordering the task by task_num, so that we only pick the task with smallest task_num.
This is to avoid unique index errors in tests, which sometime happen (only in PostgreSQL).