Gnus Manual. Node: Sorting

PREVThreading UPThe Summary Buffer NEXTAsynchronous Fetching

3.10: Sorting

If you are using a threaded summary display, you can sort the threads by setting gnus-thread-sort-functions, which is a list of functions. By default, sorting is done on article numbers. Ready-made sorting predicate functions include gnus-thread-sort-by-number, gnus-thread-sort-by-author, gnus-thread-sort-by-subject, gnus-thread-sort-by-date, gnus-thread-sort-by-score, and gnus-thread-sort-by-total-score.

Each function takes two threads and returns non-nil if the first thread should be sorted before the other. Note that sorting really is normally done by looking only at the roots of each thread. If you use more than one function, the primary sort key should be the last function in the list. You should probably always include gnus-thread-sort-by-number in the list of sorting functions---preferably first. This will ensure that threads that are equal with respect to the other sort criteria will be displayed in ascending article order.

If you would like to sort by score, then by subject, and finally by number, you could do something like:

(setq gnus-thread-sort-functions
      '(gnus-thread-sort-by-number
        gnus-thread-sort-by-subject
        gnus-thread-sort-by-total-score))

The threads that have highest score will be displayed first in the summary buffer. When threads have the same score, they will be sorted alphabetically. The threads that have the same score and the same subject will be sorted by number, which is (normally) the sequence in which the articles arrived.

If you want to sort by score and then reverse arrival order, you could say something like:

(setq gnus-thread-sort-functions
      '((lambda (t1 t2)
          (not (gnus-thread-sort-by-number t1 t2)))
        gnus-thread-sort-by-score))

The function in the gnus-thread-score-function variable (default +) is used for calculating the total score of a thread. Useful functions might be max, min, or squared means, or whatever tickles your fancy.

If you are using an unthreaded display for some strange reason or other, you have to fiddle with the gnus-article-sort-functions variable. It is very similar to the gnus-thread-sort-functions, except that it uses slightly different functions for article comparison. Available sorting predicate functions are gnus-article-sort-by-number, gnus-article-sort-by-author, gnus-article-sort-by-subject, gnus-article-sort-by-date, and gnus-article-sort-by-score.

If you want to sort an unthreaded summary display by subject, you could say something like:

(setq gnus-article-sort-functions
      '(gnus-article-sort-by-number
        gnus-article-sort-by-subject))
PREVThreading UPThe Summary Buffer NEXTAsynchronous Fetching