Quick answer - task priority is determined by the order in which tasks have to be done to achieve the goal.
Longer answer -
Going along with David's comments, I don't see where one task would be of a higher priority than another. This is going on the assumption that, if it's in the plan it's something that should/needs to be done, therefore it's equally important as the rest.
Some areas where you may need to rank tasks however would be where resources are concerned and overlapping due dates. That's where I see the ranking being used, but that would also form the basis for the prioritization.
If I have two tasks that are scheduled for the same time and the same resource, then I need to rank then to decide which one to do first. This 'might' be due to time (ie: one affects other downstream work), or it could be by duration (one will take a day while the other a week), or it could be deadline (one HAS to be done by 12/24). It could be due to a lot of factors. I think David's point though was that most of these factors should have been addressed in the initial planning.
The other instance where I see prioritization is with resources across projects. If I have a task scheduled for a week and another project has a task for the same week with the same resource, then some prioritization will have to happen. Again, ideally this would happen during planning (resource management), but it doesn't always.
The point being, the ranking/priority is going to be driven by a number of factors, most of them external. But I don't timeframe see being one of them.