|How to presort the queue||V8.7 and later|
If what is host, the messages in the queue are first sorted by recipient host, lock status, and priority. If any message for a host is locked (currently being delivered), all the messages for that host are also marked as locked. Then the queue is sorted again, this time by lock status (unlocked first), recipient host, and priority. Delivery attempts after this sort tend to group SMTP connections to the same host together sequentially.
 When there are multiple recipients, the host is taken from the first recipient in the list. If that recipient is successfully delivered but others are deferred, a different recipient will be first in the next queue run. That new first recipient can result in a new host for the sort.
Be careful in sorting by host. If you have a large backlog of low-priority (batch) mail on a low-speed link to some host (for example, news), you might end up delaying higher-priority mail intended for other hosts. The host sort is recommended for high-speed links but is less desirable on low-speed links.
The method to order a queue run that has been used by sendmail for many years is a simple sort of the message priorities. A message's priority is found in the qf file's P line (P line). The sort is based on cost. That is, low (less positive) priorities are sorted ahead of high (more positive) values.
Beginning with V8.8, sendmail recognizes the time keyword, which causes it to sort based on submission time. This setting is not intended for use in the configuration file. Instead, it should be used only from the command line and in combination with the -qR command-line switch (Section 220.127.116.11).
If you wrongly set time in the configuration file, large and old jobs will be sorted in with small, new jobs. This can delay important mail.
Beginning with V8.10, sendmail recognizes the filename keyword, which causes it to sort based on filenames in the queue directory. This setting is not intended for use in the configuration file. Instead, it should be used when queues are unusually deep, as a fast way to process the queue.
The preceding sort modes open and read every qf file, dramatically slowing down the sort. Because the sort must happen before sendmail will begin processing the queue, such a slowdown on a very deep directory can lead to serious bottlenecks. This filename sorts on filename only, and does not open qf files to read them. See Section 6.1 for a description of how to handle deep queues.
Beginning with V8.12, sendmail recognizes the random keyword, which causes it to sort using a pseudorandomizer so that the list of envelopes ends up in a pseudorandom order. This setting is not intended for use in the configuration file. Instead, it should be used when queues are unusually deep, as a fast way to process the queue. Like the filename keyword, this mode avoids the cost of opening and reading every qf file. Unlike filename, however, parallel queue runners will have different lists to process. This avoids lock and other contentions that could somewhat slow a queue run.
Beginning with V8.12, sendmail recognizes the modtime keyword, which causes it to sort based on the modification time of each qf file. The list is ordered in reverse, so the oldest qf files are processed first. Although you can set modtime in the configuration file, it has the potential to unacceptably delay important new mail. In general, this setting is better used as part of a command-line invocation of sendmail.