emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Two tables with same data but different sorting


From: John Kitchin
Subject: Re: Two tables with same data but different sorting
Date: Thu, 1 Oct 2020 08:21:20 -0400

You could do something like this:


* Table 1

#+name: table1
| Manufacturer    | Name        | Price |
|-----------------+-------------+-------|
| ACME            | super cheep | 25 $  |
| Roadrunner Inc. | Kaboom      | 27 $  |
| ACME            | cheep       | 30 $  |

#+RESULTS: resorted
| Manufacturer    | Name        | Price |
|-----------------+-------------+-------|
| ACME            | super cheep | 25 $  |
| ACME            | cheep       | 30 $  |
| Roadrunner Inc. | Kaboom      | 27 $  |

** Code for resorting

#+name: resorted
#+BEGIN_SRC emacs-lisp :var data="" :colnames t
(sort data (lambda (row1 row2) (string< (first row1) (first row2))))
#+END_SRC

John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Thu, Oct 1, 2020 at 4:57 AM Axel Kielhorn <org-mode@axelkielhorn.de> wrote:
Hello!

I have a table that I want to show with two different sorting orders but I don’t want to maintain the data twice.


* Table 1

| Manufacturer    | Name        | Price |
|-----------------+-------------+-------|
| ACME            | super cheep | 25 $  |
| Roadrunner Inc. | Kaboom      | 27 $  |
| ACME            | cheep       | 30 $  |

*  Table 2

| Manufacturer    | Name        | Price |
|-----------------+-------------+-------|
| ACME            | cheep       | 30 $  |
| ACME            | super cheep | 25 $  |
| Roadrunner Inc. | Kaboom      | 27 $  |

Is there a way to do this in org?
Right now I copy the table and apply an =C-c ^ a= on the first column.

Greetings
Axel

reply via email to

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