Next: Rmail Display, Previous: Rmail Summary, Up: Rmail [Contents][Index]

### 33.12 Sorting the Rmail File

`C-c C-s C-d`
`M-x rmail-sort-by-date`

  Sort messages of current Rmail buffer by date.

`C-c C-s C-s`
`M-x rmail-sort-by-subject`

  Sort messages of current Rmail buffer by subject.

`C-c C-s C-a`
`M-x rmail-sort-by-author`

  Sort messages of current Rmail buffer by author’s name.

`C-c C-s C-r`
`M-x rmail-sort-by-recipient`

  Sort messages of current Rmail buffer by recipient’s names.

`C-c C-s C-c`
`M-x rmail-sort-by-correspondent`

  Sort messages of current Rmail buffer by the name of the other correspondent.

`C-c C-s C-l`
`M-x rmail-sort-by-lines`

  Sort messages of current Rmail buffer by number of lines.

`C-c C-s C-k RET labels RET`
`M-x rmail-sort-by-labels RET labels RET`

  Sort messages of current Rmail buffer by labels. The argument labels should be a comma-separated list of labels. The order of these labels specifies the order of messages; messages with the first label come first, messages with the second label come second, and so on. Messages that have none of these labels come last.

The Rmail sort commands perform a stable sort: if there is no reason to prefer either one of two messages, their order remains unchanged. You can use this to sort by more than one criterion. For example, if you use `rmail-sort-by-date` and then `rmail-sort-by-author`, messages from the same author appear in order by date.

With a prefix argument, all these commands reverse the order of comparison. This means they sort messages from newest to oldest, from biggest to smallest, or in reverse alphabetical order.

The same keys in the summary buffer run similar functions; for example, `C-c C-s C-l` runs `rmail-summary-sort-by-lines`. Note that these commands always sort the whole Rmail buffer, even if the summary is only showing a subset of messages.

Note that you cannot undo a sort, so you may wish to save the Rmail buffer before sorting it.

Next: Rmail Display, Previous: Rmail Summary, Up: Rmail [Contents][Index]