I have an org-mode file in standard agenda format:

* Dentist
* Put up shelves

I'm just starting to use org-agenda but I still use just that single file a lot just as an regular org-mode fully-expanded tree, and it's handy to have it kept sorted in date order.

Currently I sort it by hand. How can I get emacs to sort it by date?

  • Here is an advanced example of programmatically sorting by multiple criteria the main org-mode buffer: stackoverflow.com/a/22232709/2112489 I sort automatically with a prompt yes/new each time I open my master calendar org-mode file, and whenever I add a new task/event, or whenever I modify an existing task/event, except a few circumstances where I don't want to see it moving around until I call a programmatic sort interactively.
    – lawlist
    Sep 4, 2015 at 14:11

1 Answer 1


Just select the entire buffer and do C-c^ (it runs the command org-sort). It will prompt you for the type of sorting.

To understand different types of sorting see the documentation of org-sort-entries (M-xorg-sort-entriesRET). I am quoting it here for completeness

Sort entries on a certain level of an outline tree. If there is an active region, the entries in the region are sorted. Else, if the cursor is before the first entry, sort the top-level items. Else, the children of the entry at point are sorted.

Sorting can be alphabetically, numerically, by date/time as given by a time stamp, by a property, by priority order, or by a custom function.

The command prompts for the sorting type unless it has been given to the function through the SORTING-TYPE argument, which needs to be a character, (?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?o ?O ?r ?R ?f ?F ?k ?K). Here is the precise meaning of each character:

a Alphabetically, ignoring the TODO keyword and the priority, if any.

c By creation time, which is assumed to be the first inactive time stamp at the beginning of a line.

d By deadline date/time.

k By clocking time.

n Numerically, by converting the beginning of the entry/item to a number.

o By order of TODO keywords.

p By priority according to the cookie.

r By the value of a property.

s By scheduled date/time.

t By date/time, either the first active time stamp in the entry, or, if none exist, by the first inactive one.

Capital letters will reverse the sort order.

  • 1
    What took me much time to understand is that sorting by multiple criteria can be accomplished programmatically by running org-sort-entries several times in a row with different sorts -- e.g., (org-sort-entries t ?a) (org-sort-entries t ?o) (org-sort-entries t ?p) (org-sort-entries t ?t)
    – lawlist
    Sep 4, 2015 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.