When creating AFT transfers, there is a 'priority' feature you can set in cases where the same "from" account is used to pay on multiple "to" accounts on the same schedule. This priority code lets you specify which transfer should be done first, next, and so on, so if that priority code had been specified, the system would attempt to satisfy the payments in that order, all else being equal.
If there is no priority, the system simply gathers all of the transfer records it needs to satisfy and works through them in order by account suffix. So a transfer to loan -786 would be done before one to loan -851.
Remember that the payment date and delinquency controls settings you use also play a role here, to determine whether a payment should be made or not based on the status of the loan account itself. (See the related link below for more on these settings.) But once the AFT itself is past due and the system is trying to catch up, these rules are less of a factor as the system is simply trying to complete the past-due transfers, in order by account as described. There is no mechanism to look at how past-due a particular loan is and shuffle the past-due AFTs accordingly.