All, Here is version two of the imap SORT command i got to thinking about that first one using msort on the list, and that was just stupid. So I made up a quick binary tree and all is much happier now. This still needs a lot of work and still needs the header caching but at least now it does swamp the cpu. Anything over about 1000 messages tring to sort by subject, to or from just takes to much time for a webmail browser to keep connected. If there wasn't the overhead of parsing the headers I belive this would be a valid implementation, also you could just do the sorting in the SQL order by command if the headers where chached :). The only thing I add that is nessary is the addition of the mid appended to the string to make it uniq, the imap SORT rfc accualy states that if two messages are the same string for the sort then you need to compare order of arrival, this is done by default with the mid's.
Comments? Thanks, leif
dbmail-2.0cvs031804-ic_sort-v2.diff
Description: Binary data
