Created attachment 2006 [details] Patch to allow sorting by thread number in addition to thread date This allows effectively sorting by received-date of the last message in each thread. Sorting by date leads to unexpected behaviour sometimes, as some messages' Date headers are missing or incorrect.
Created attachment 2007 [details] Patch to clean up summary comparison functions This is a patch that changes all summary comparison functions to have the requisite error checks and now behaviour is consistent between the different comparison algorithms (unset is now always counted as a maximal value for sorting). Comparison functions never return 0 unless the two messages compared are in fact the same. This patch depends on the previous one, although trivially so. If I should resubmit without the dependency, please let me know. Also, this changes the existing behaviour of sorting by date - previously messages (or threads) without date set were not placed in a well defined position (although it would typically be at the bottom). Now, such messages are placed at the top of the list to be consistent with the other sorting methods. Another thought I had about the sorting options - is sorting by date really the right fallback option if comparison by the others fails. If message ID is guaranteed to be present, sorting by it would seem to be a better solution. Is that the case on all setups though?