From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ryan C. Thompson" Subject: Re: Useful utility function: org-sort-multi Date: Sun, 30 Aug 2009 13:55:45 -0700 Message-ID: <4A9AE751.2080208@thompsonclan.org> References: <4A988678.6020202@gmail.com> <87ab1hsnte.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MhrVS-0006Al-Gs for emacs-orgmode@gnu.org; Sun, 30 Aug 2009 17:00:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MhrVO-00069L-W5 for emacs-orgmode@gnu.org; Sun, 30 Aug 2009 17:00:10 -0400 Received: from [199.232.76.173] (port=50291 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhrVO-000699-KU for emacs-orgmode@gnu.org; Sun, 30 Aug 2009 17:00:06 -0400 Received: from lo.gmane.org ([80.91.229.12]:59092) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MhrVN-0000t2-Tl for emacs-orgmode@gnu.org; Sun, 30 Aug 2009 17:00:06 -0400 Received: from list by lo.gmane.org with local (Exim 4.50) id 1MhrVL-0000Mp-7L for emacs-orgmode@gnu.org; Sun, 30 Aug 2009 23:00:03 +0200 Received: from user-0c9h9j2.cable.mindspring.com ([24.152.166.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 30 Aug 2009 23:00:03 +0200 Received: from rct by user-0c9h9j2.cable.mindspring.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 30 Aug 2009 23:00:03 +0200 In-Reply-To: <87ab1hsnte.fsf@gmail.com> 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 Cc: org-mode Mailinglist Benjamin Andresen wrote: > if you have the following list > * Test Sorting > ** TODO Charlie > ** WAITING Beta > ** TODO Alpha > ** STARTED Beta > ** STARTED Charlie > ** TODO Beta > ** STARTED Alpha > ** WAITING Charlie > ** WAITING Alpha > calling org-multi-sort with ?o ?a will sort it like this > * Test Sorting > ** TODO Alpha > ** TODO Beta > ** TODO Charlie > ** STARTED Alpha > ** STARTED Beta > ** STARTED Charlie > ** WAITING Alpha > ** WAITING Beta > ** WAITING Charlie > but just ?a would completely ignore the TODO, STARTED, WAITING order. > Thanks Ryan, pretty useful. > br, > benny > _______________________________________________ > 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 That's right, the function relies on the fact that org's sorting is stable. So the results of earlier sorts are preserved as much as possible in later sorts. Of course, this is really inefficient, but oh well. As another test case, try using (org-sort-multi ?o ?p) on this: * Multi-sort test ** DONE [#B] ** TODO [#C] ** STARTED [#C] ** STARTED [#A] ** DONE [#C] ** TODO [#B] ** TODO [#A] ** STARTED [#B] ** DONE [#A] Anyway, Carsten, if you think this would be useful, feel free to include some variant of this in org-mode itself. You'd probably want to implement it as a one-pass sort in which the set of sorting criteria function as a series of fallbacks for tiebreakers, rather than a series of sorts. Ryan