From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sanjib Sikder Subject: Re: Sort Phrases Date: Mon, 22 Oct 2012 23:44:49 +0530 Message-ID: References: <1350906016.77719.YahooMailNeo@web29804.mail.ird.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=14dae934126bb3ed2d04cca9d66e Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQMXF-000636-Ib for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:15:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQMXD-0002mt-QB for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:15:33 -0400 Received: from mail-ia0-f169.google.com ([209.85.210.169]:58710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQMXD-0002l8-JG for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:15:31 -0400 Received: by mail-ia0-f169.google.com with SMTP id h37so2988473iak.0 for ; Mon, 22 Oct 2012 11:15:30 -0700 (PDT) In-Reply-To: <1350906016.77719.YahooMailNeo@web29804.mail.ird.yahoo.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Giovanni Ridolfi Cc: "emacs-orgmode@gnu.org" --14dae934126bb3ed2d04cca9d66e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Giovanni, You need to put the following lines into your .emacs to sort WORDS and LINES. --8<---------------cut here---------------start------------->8--- ;;;Sort words (defun sort-words (reverse beg end) "Sort words in region alphabetically, in REVERSE if negative. Prefixed with negative \\[universal-argument], sorts in reverse. The variable `sort-fold-case' determines whether alphabetic case affects the sort order. See `sort-regexp-fields'." (interactive "*P\nr") (sort-regexp-fields reverse "\\w+" "\\&" beg end)) --8<---------------cut here---------------start------------->8--- Then to sort words like apple, mango, oranges, cat, elephant You need to do M-x sort-words To sort lines, similarly do M-x sort-lines ----------------------------- *Sanjib Sikder *Ph.D. Fellow Chemical Engineering IIT Bombay* * On Mon, Oct 22, 2012 at 5:10 PM, Giovanni Ridolfi wrote: > Da: Sanjib Sikder > > Inviato: Luned=EC 22 Ottobre 2012 13:27 > > > > I know it is possible to sort words and sort lines alphabetically in > emacs org-mode > > Would you please be so kind to explain to me how? > > I have only: > org-sort-entries M-x ... RET Sort entries on a certain level > of an outline tree. > org-sort-list M-x ... RET Sort list items. > org-table-sort-lines in = a > table. > > > Is it possible to sort words like: > > banana fruit chees apple > > or lines like > > > banana > > fruit > chees > > apple > > > > > but is it possible to sort phrases ? > > > Face the music, Fifteen minutes of fame, A beautiful mind. > > I want to sort it alphabetically like, > > A beautiful mind, Face the music, Fifteen minutes of fame. > > In Emacs everything is possible. > > - substitute "," with \n > - sort region > - substitute \n with "," > > Cheers, > > Giovanni > > --14dae934126bb3ed2d04cca9d66e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Giovanni,

You need to put the following lines into your .emacs to= sort WORDS and LINES.

--8<---------------cut here---------------start------------->8---
=
;;;Sort words
=A0(defun sort-words (reverse beg end)
=A0=A0=A0=A0= =A0 "Sort words in region alphabetically, in REVERSE if negative.
= =A0=A0=A0 Prefixed with negative \\[universal-argument], sorts in reverse.<= br> =A0=A0=A0 The variable `sort-fold-case' determines whether alphabetic c= ase
=A0=A0=A0 affects the sort order.
=A0=A0=A0 See `sort-regexp-fiel= ds'."
=A0=A0=A0=A0=A0 (interactive "*P\nr")
=A0=A0= =A0=A0=A0 (sort-regexp-fields reverse "\\w+" "\\&" = beg end))

--8<---------------cut here---------------start------------->8---

Then to sort words like

apple, mango, oranges, ca= t, elephant

You need to do

M-x sort-words

To sort line= s, similarly do

M-x sort-lines


-----------------------------
Sanjib Sikder=
Ph.D. Fellow
Chemical Eng= ineering
IIT Bombay






On Mon, Oct 22, 2012 at 5:10 PM, Giovann= i Ridolfi <giovanni.ridolfi@yahoo.it> wrote:
Da: Sanjib Sikder <sanjibju200= 2@gmail.com>

Inviato: Luned=EC 22 Ottobre 2012 13:27


> I know it is possible to sort words and sort lines alphabetically in e= macs org-mode

Would you please be so kind to explain to me how?

I have only:
org-sort-entries=A0=A0=A0 =A0=A0=A0=A0=A0 M-x ... RET =A0 =A0 Sort entries = on a certain level of an outline tree.
org-sort-list=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0 M-x ... RET =A0 =A0 =A0 So= rt list items.
org-table-sort-lines=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 <Sort lines in region> in a table.


Is it possible to sort words like:

banana fruit chees=A0 apple

or lines like


banana

fruit
chees

apple



> but is it possible to sort phrases ?

> Face the music, Fifteen minutes of fame, A bea= utiful mind.
> I want to sort it alphabetically like,
>=A0 A beautiful mind, Face the music, Fifteen minutes of fame.

In Emacs everything is possible.

- substitute "," with \n
- sort region
- substitute \n with ","

Cheers,

Giovanni


--14dae934126bb3ed2d04cca9d66e--