From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Pechiar Subject: Re: Sorting table columns (*not* content) Date: Mon, 1 Nov 2010 12:43:42 -0200 Message-ID: <20101101144342.GA2450@soloJazz.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=34459 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCvbz-00079R-52 for emacs-orgmode@gnu.org; Mon, 01 Nov 2010 10:43:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PCvbx-0006Io-Ma for emacs-orgmode@gnu.org; Mon, 01 Nov 2010 10:43:51 -0400 Received: from cpoproxy3-pub.bluehost.com ([67.222.54.6]:41109) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PCvbx-0006ID-GW for emacs-orgmode@gnu.org; Mon, 01 Nov 2010 10:43:49 -0400 Received: from r186-48-201-207.dialup.adsl.anteldata.net.uy ([186.48.201.207] helo=iso.palmas.net) by box519.bluehost.com with esmtpa (Exim 4.69) (envelope-from ) id 1PCvbt-0003tq-CN for emacs-orgmode@gnu.org; Mon, 01 Nov 2010 08:43:45 -0600 Content-Disposition: inline In-Reply-To: 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: emacs-orgmode@gnu.org If you don't mind losing h-lines, you can transpose the table, sort rows, and transpose back. This code (which I previously posted to the list) transposes a table: #+begin_src: emacs-lisp (defun org-transpose-table-at-point () "Transpose orgmode table at point, eliminate hlines" (interactive) (let ((contents (apply #'mapcar* #'list (remove-if-not 'listp ;; remove 'hline from list (org-table-to-lisp)))) ;; signals error if not table ) (delete-region (org-table-begin) (org-table-end)) (insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " |\n" )) contents "")) (org-table-align) ) ) #+end_src Regards, .j. On Mon, Nov 01, 2010 at 02:42:55PM +0100, Gary wrote: > Is there any way to sort the columns of a table, such that for example > > | Col 3 | Col 1 | Col 2 | > > can be converted to > > | Col 1 | Col 2 | Col 3 | > |-------+-------+-------| > | ... | ... | ... | > > ?