Network Working Group M. Crispin Internet Draft: IMAP SORT University of Washington Document: internet-drafts/draft-crispin-imap-sort-00.txt February 1998 INTERNET MESSAGE ACCESS PROTOCOL - SORT EXTENSION Status of this Memo This document is an Internet-Draft. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." To learn the current status of any Internet-Draft, please check the "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow Directories on ds.internic.net (US East Coast), nic.nordu.net (Europe), ftp.isi.edu (US West Coast), or munnari.oz.au (Pacific Rim). A revised version of this draft document will be submitted to the RFC editor as an Informational RFC for the Internet Community. Discussion and suggestions for improvement are requested, and should be sent to imap@CAC.Washington.EDU. This document will expire before 31 August 1998. Distribution of this memo is unlimited. Abstract This document describes the server-based sorting extension to the IMAP4rev1 protocol. This extension provides substantial performance improvements for IMAP clients which offer sorted views. Crispin [Page 1] INTERNET DRAFT IMAP SORT November 1997 Additional Commands This command is an extension to the IMAP4rev1 base protocol. The section header is intended to correspond with where it would be located in the main document if it was part of the base specification. 6.3.SORT. SORT Command Arguments: sort program charset specification searching criteria (one or more) Data: untagged responses: SORT Result: OK - sort completed NO - sort error: can't sort that charset or criteria BAD - command unknown or arguments invalid The SORT command is a variant of SEARCH with sorting semantics for the results. Sort has two arguments before the searching criteria argument; a parenthesized list of sort criteria, and the searching charset. Note that unlike SEARCH, the searching charset argument is mandatory. There is also a UID SORT command which corresponds to SORT the way that UID SEARCH corresponds to SEARCH. The SORT command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation of strings in the searching criteria. It then returns the matching messages in an untagged SORT response, sorted according to one or more sort criteria. Unlike SEARCH, if no messages match the searching criteria in a SORT command, no untagged SORT response is returned. When multiple sort criteria are specified, the result is sorted in the priority order that the criteria appear. For example, (SUBJECT DATE) will sort messages in order by their subject text; and for messages with the same subject text will sort by their sent date. Crispin [Page 2] INTERNET DRAFT IMAP SORT November 1997 The defined sort criteria are as follows. Refer to the Formal Syntax section for the precise syntactic definitions of the arguments. ARRIVAL Internal date of the message. CC Mailbox part of the first "cc" address. DATE Sent date from the Date: header. FROM Mailbox part of the "From" address. REVERSE Followed by another sort criterion, has the effect of that criterion but in reverse order. SIZE Size of the message in octets. SUBJECT Subject text TO Mailbox part of the first "To" address. Example: C: A282 SORT (SUBJECT) UTF-8 SINCE 1-Feb-1994 S: * SORT 2 84 882 S: A282 OK SORT completed C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 ALL S: * SORT 5 3 4 1 2 S: A283 OK SORT completed C: A284 SORT (SUBJECT) US-ASCII TEXT "not in mailbox" S: A284 OK SEARCH completed Crispin [Page 3] INTERNET DRAFT IMAP SORT November 1997 Additional Responses This response is an extension to the IMAP4rev1 base protocol. The section heading of this response is intended to correspond with where it would be located in the main document. 7.2.SORT. SORT Response Data: one or more numbers The SORT response occurs as a result of a SORT or UID SORT command. The number(s) refer to those messages that match the search criteria. For SORT, these are message sequence numbers; for UID SORT, these are unique identifiers. Each number is delimited by a space. Example: S: * SORT 2 3 6 Crispin [Page 4] INTERNET DRAFT IMAP SORT November 1997 Formal Syntax of SORT commands and Responses sort_data ::= "SORT" SPACE 1#nz_number sort ::= ["UID" SPACE] "SORT" SPACE "(" 1#sort_criterion ")" SPACE search_charset SPACE 1#search_key sort_criterion ::= ["REVERSE" SPACE] sort_key sort_key ::= "ARRIVAL" / "CC" / "DATE" / "FROM" / "SIZE" / "SUBJECT" / "TO" Security Considerations Security issues are not discussed in this memo. Internationalization Considerations By default, strings are sorted according to the default locale. In the default locale, the 26 Latin alphabetics are sorted in a case-insensitive fashion; that is, "A" and "a" are treated as exact equals. All other characters are sorted according to their octet values as expressed in UTF-8. Other locales, and the ability to change the locale, will be defined in a separate extension and document. It is anticipated that there will be a generic Unicode locale which provides generic case-insensitivity for alphabetic scripts, as well as language- specific locales. A server which implements non-default locales will modify its sorting behavior according to the locale. Author's Address Mark R. Crispin Networks and Distributed Computing University of Washington 4545 15th Aveneue NE Seattle, WA 98105-4527 Phone: (206) 543-5762 EMail: MRC@CAC.Washington.EDU Crispin [Page 5]