From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Sorting subheaders Date: Thu, 13 Aug 2009 11:12:35 -0400 Message-ID: <87ab23ycgs.fsf@stats.ox.ac.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mbbyx-0005n6-8J for emacs-orgmode@gnu.org; Thu, 13 Aug 2009 11:12:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mbbys-0005f1-5w for emacs-orgmode@gnu.org; Thu, 13 Aug 2009 11:12:46 -0400 Received: from [199.232.76.173] (port=40975 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mbbyr-0005ee-V6 for emacs-orgmode@gnu.org; Thu, 13 Aug 2009 11:12:41 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:59759) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mbbyr-0004U5-Dk for emacs-orgmode@gnu.org; Thu, 13 Aug 2009 11:12:41 -0400 In-Reply-To: (Scott Novotney's message of "Tue, 11 Aug 2009 11:29:35 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Scott Novotney Cc: emacs-orgmode@gnu.org Scott Novotney 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