emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Sorting table columns (*not* content)


From: brian powell
Subject: Re: [Orgmode] Sorting table columns (*not* content)
Date: Mon, 1 Nov 2010 11:39:53 -0400

Jeff Horn seems to be explaining specifics of how to do some nitty-gritty manipulations--he mentions (quoting the manual) methods for yanking, Ccxy

The methods Jeff expressed are useful for the question posed.

I recommend rectangle-kill and rectangle-yank--Cxrk and Cxry to solve this (in a very simple albeit possibly faster or slower way--depending on how many columns you want to move/sort---moving column/rectangle 3 to the 3rd position in this case--took a few seconds)

I tested Juan's method/defun---works grrrrreat!!
Thanks Juan

P.S. I did lose the hlines like you reported; but, to put the line back was 3 key strokes: |-Tab

On Mon, Nov 1, 2010 at 10:43 AM, Juan Pechiar <address@hidden> wrote:
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 |
> |-------+-------+-------|
> | ...   | ...   | ...   |
>
> ?

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


reply via email to

[Prev in Thread] Current Thread [Next in Thread]