UIDS are fetched using one of three methods in the hastymail2/lib/imap_class.php file, which one is used is determined by the IMAP server's support for the IMAP SORT and THREAD commands.
server_side_sort
This is the preferred method and is used when the server supports the IMAP SORT command. We issue a SORT command on a selected mailbox and the server returns a space delimited set of message UIDS that we assign to the uid cache in the session.
client_side_sort
This method is used when the IMAP server does not support the SORT command. We issue an IMAP FETCH command and the server returns a FETCH response from which we can grab the message UIDS
thread_sort
This method is used when the IMAP server supports the THREAD command and the user has selected to thread sort the mailbox. It is similar to the SORT command however the returned message UIDS are nested in parenthesis to indicate the thread association.
Hope that helps,
Jason