emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: Scott Novotney <snovotney@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Sorting subheaders
Date: Thu, 13 Aug 2009 11:12:35 -0400	[thread overview]
Message-ID: <87ab23ycgs.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <ba713d8c0908110829v448a72b7q2f1ecd08fe2d9510@mail.gmail.com> (Scott Novotney's message of "Tue, 11 Aug 2009 11:29:35 -0400")

Scott Novotney <snovotney@gmail.com> writes:

> Hello,
>
> Does anyone know a way to sort headers or subheaders? I can sort items by time in the agenda view,
> but something more powerful, possibly by :TAG: or just by name would be very useful.

You want org-sort.

To sort your example by name, put the cursor in the top level heading (*
Top) and then use M-x org-sort, and select 'a' for alphanumeric
sort. org-sort calls org-sort-entries-or-items (unless you're in a
table). Below is the documentation for that (C-h f org-sort-entries-or-items)

[It looks like the main index of the manual needs a n entry under 'sort'
or 'sorting'. Currently there's only one for sorting in the agenda.]

Dan

,----
| org-sort-entries-or-items is an interactive compiled Lisp function in
| `org.el'.
| 
| (org-sort-entries-or-items &optional with-case sorting-type
| getkey-func compare-func property)
| 
| Sort entries on a certain level of an outline tree, or plain list items.
| 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.
| If the cursor is at the first item in a plain list, the list items will be
| sorted.
| 
| Sorting can be alphabetically, numerically, by date/time as given by
| a time stamp, by a property or by priority.
| 
| The command prompts for the sorting type unless it has been given to the
| function through the sorting-type argument, which needs to a character,
| (?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?r ?R ?f ?F).  Here is the
| precise meaning of each character:
| 
| n   Numerically, by converting the beginning of the entry/item to a number.
| a   Alphabetically, ignoring the TODO keyword and the priority, if any.
| t   By date/time, either the first active time stamp in the entry, or, if
|     none exist, by the first inactive one.
|     In items, only the first line will be chekced.
| s   By the scheduled date/time.
| d   By deadline date/time.
| c   By creation time, which is assumed to be the first inactive time stamp
|     at the beginning of a line.
| p   By priority according to the cookie.
| r   By the value of a property.
| 
| Capital letters will reverse the sort order.
| 
| If the sorting-type is ?f or ?F, then getkey-func specifies a function to be
| called with point at the beginning of the record.  It must return either
| a string or a number that should serve as the sorting key for that record.
| 
| Comparing entries ignores case by default.  However, with an optional argument
| with-case, the sorting considers case as well.
`----


>
> Example:
>
> * Top
> ** C
> ** B
> ** A
>
> -----------------------------------------------------
> after some magic key combination
> -----------------------------------------------------
>
> * Top
> ** A
> ** B
> ** C
>
> Thanks!
>
> -Scott
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2009-08-13 15:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11 15:29 Sorting subheaders Scott Novotney
2009-08-13 15:12 ` Dan Davison [this message]
2009-08-13 17:15   ` [PATCH] " Dan Davison
2009-08-14 11:05     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ab23ycgs.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=snovotney@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).