unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19896: 23.1; reverse-region is slow compared to sort-columns
       [not found] <1372534272.5818344.1424278471675.JavaMail.zimbra@comcast.net>
@ 2015-02-18 17:35 ` asparagus
  2015-02-18 18:29   ` Ivan Shmakov
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: asparagus @ 2015-02-18 17:35 UTC (permalink / raw)
  To: 19896

The emacs manual recommends 'M-x reverse-region' as a companion to 'M-x sort-columns' to achieve a descending-order column sort.  However, for large regions (>100k lines), 'M-x reverse-region' is noticeably slower than 'M-x sort-columns', making descending sort much slower than ascending sort.

A workaround on linux: use 'C-u M-x shell-command-on-region' with tac (the opposite of cat) instead of using 'M-x reverse-region'.

FROM THE MANUAL:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Sorting.html
M-x reverse-region
    Reverse the order of the lines in the region. This is useful for sorting into descending order by fields or columns, since those sort commands do not have a feature for doing that.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: 23.1; reverse-region is slow compared to sort-columns
  2015-02-18 17:35 ` bug#19896: 23.1; reverse-region is slow compared to sort-columns asparagus
@ 2015-02-18 18:29   ` Ivan Shmakov
  2015-02-18 19:01     ` Eli Zaretskii
       [not found]   ` <1358494426.5913572.1424285832847.JavaMail.zimbra@comcast.net>
       [not found]   ` <215096857.10629626.1424972910085.JavaMail.zimbra@comcast.net>
  2 siblings, 1 reply; 8+ messages in thread
From: Ivan Shmakov @ 2015-02-18 18:29 UTC (permalink / raw)
  To: 19896, asparagus

>>>>> asparagus  <asparagus@comcast.net> writes:

 > The emacs manual recommends 'M-x reverse-region' as a companion to
 > 'M-x sort-columns' to achieve a descending-order column sort.

	This could be a bug in the manual, as sort-columns has an
	optional (prefix) ‘reverse’ argument since at least 1990
	(d32200ac.)

 > However, for large regions (> 100k lines), 'M-x reverse-region' is
 > noticeably slower than 'M-x sort-columns', making descending sort
 > much slower than ascending sort.

	I don’t seem to see this on the current master; at a glance,
	M-x reverse-region takes less time to complete than
	M-x sort-columns.

	The current stable version of Emacs is 24.4, with the pretest
	for 24.5 being available since 17th [1].  Could you please check
	if this issue also manifests with either of these versions?

	TIA.

[1] news:87mw4c6gjn.fsf@petton.fr
    http://permalink.gmane.org/gmane.emacs.devel/183187

 > A workaround on linux: use 'C-u M-x shell-command-on-region' with tac
 > (the opposite of cat) instead of using 'M-x reverse-region'.

	On a GNU system (as well as on any other system featuring
	GNU Coreutils), it should be possible to just use sort(1) for
	the purpose.  For instance, the “reverse” option is ‘-r’.

[…]

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: 23.1; reverse-region is slow compared to sort-columns
  2015-02-18 18:29   ` Ivan Shmakov
@ 2015-02-18 19:01     ` Eli Zaretskii
  2015-02-18 19:13       ` Ivan Shmakov
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2015-02-18 19:01 UTC (permalink / raw)
  To: Ivan Shmakov; +Cc: 19896

> From: Ivan Shmakov <ivan@siamics.net>
> Date: Wed, 18 Feb 2015 18:29:08 +0000
> 
>  > A workaround on linux: use 'C-u M-x shell-command-on-region' with tac
>  > (the opposite of cat) instead of using 'M-x reverse-region'.
> 
> 	On a GNU system (as well as on any other system featuring
> 	GNU Coreutils), it should be possible to just use sort(1) for
> 	the purpose.  For instance, the “reverse” option is ‘-r’.

But sort(1)'s sort order is locale-specific, whereas that of Emacs
isn't.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: 23.1; reverse-region is slow compared to sort-columns
  2015-02-18 19:01     ` Eli Zaretskii
@ 2015-02-18 19:13       ` Ivan Shmakov
  2015-02-18 19:29         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Ivan Shmakov @ 2015-02-18 19:13 UTC (permalink / raw)
  To: 19896

>>>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>>> From: Ivan Shmakov  Date: Wed, 18 Feb 2015 18:29:08 +0000

[…]

 >> On a GNU system (as well as on any other system featuring GNU
 >> Coreutils), it should be possible to just use sort(1) for the
 >> purpose.  For instance, the “reverse” option is ‘-r’.

 > But sort(1)'s sort order is locale-specific, whereas that of Emacs
 > isn't.

	How is that a disadvantage?  The user can easily force any
	locale of those available on the system with an explicit
	LC_ALL=, like:

$ LC_ALL=de_DE.UTF-8 sort < list.de 

$ LC_ALL=ru_RU.UTF-8 sort < list.ru 

$ LC_ALL=C sort < list.ascii 

	For one thing, M-x sort-lines seems to put ё after я, while in
	Russian it comes between е and ж.  And similarly for ß (and the
	accented letters) in German, etc.

-- 
FSF associate member #7257  np. Bombtrack — clawz/bomb  … 3013 B6A0 230E 334A





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896:
       [not found]   ` <1358494426.5913572.1424285832847.JavaMail.zimbra@comcast.net>
@ 2015-02-18 19:19     ` asparagus
  0 siblings, 0 replies; 8+ messages in thread
From: asparagus @ 2015-02-18 19:19 UTC (permalink / raw)
  To: 19896

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

Thanks for identifying the bug in the manual. 

I do not have access to the latest versions of emacs, but thank you for verifying that reverse-region has an efficient implementation in the latest version. 

Given that reverse-region is efficiently implemented in the latest versions, correcting the manual entries for sort-columns and reverse-region would provide resolution to this issue. 


[-- Attachment #2: Type: text/html, Size: 714 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: 23.1; reverse-region is slow compared to sort-columns
  2015-02-18 19:13       ` Ivan Shmakov
@ 2015-02-18 19:29         ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2015-02-18 19:29 UTC (permalink / raw)
  To: Ivan Shmakov; +Cc: 19896

> From: Ivan Shmakov <ivan@siamics.net>
> Date: Wed, 18 Feb 2015 19:13:00 +0000
> 
> >>>>> Eli Zaretskii <eliz@gnu.org> writes:
> >>>>> From: Ivan Shmakov  Date: Wed, 18 Feb 2015 18:29:08 +0000
> 
> […]
> 
>  >> On a GNU system (as well as on any other system featuring GNU
>  >> Coreutils), it should be possible to just use sort(1) for the
>  >> purpose.  For instance, the “reverse” option is ‘-r’.
> 
>  > But sort(1)'s sort order is locale-specific, whereas that of Emacs
>  > isn't.
> 
> 	How is that a disadvantage?

I didn't say it was a disadvantage, only that the results might be
different, and will almost certainly be different in different
locales.

>       The user can easily force any locale of those available on the
> 	system with an explicit LC_ALL=, like:
> 
> $ LC_ALL=de_DE.UTF-8 sort < list.de 
> 
> $ LC_ALL=ru_RU.UTF-8 sort < list.ru 
> 
> $ LC_ALL=C sort < list.ascii 

Yes, but Emacs's sort order is not in any locale, more or less.  So
it's not easy to find a locale that will produce the same order as
Emacs, unless you know a lot about Emacs internals.  And even if you
do, such a locale might not be installed on the end-user's machine.

> 	For one thing, M-x sort-lines seems to put ё after я, while in
> 	Russian it comes between е and ж.  And similarly for ß (and the
> 	accented letters) in German, etc.

Precisely!  That was my point.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: Please modify documentation to close this bug
       [not found]   ` <215096857.10629626.1424972910085.JavaMail.zimbra@comcast.net>
@ 2015-02-26 17:53     ` asparagus
  2015-04-19  0:49       ` Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: asparagus @ 2015-02-26 17:53 UTC (permalink / raw)
  To: 19896

To close this bug, please modify
https://www.gnu.org/software/emacs/manual/html_node/emacs/Sorting.html
as follows:

Add the following to the description of M-x sort-columns:
"A numeric argument means sort into descending order."

Remove "or columns" from the description of M-x reverse-region.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19896: Please modify documentation to close this bug
  2015-02-26 17:53     ` bug#19896: Please modify documentation to close this bug asparagus
@ 2015-04-19  0:49       ` Glenn Morris
  0 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2015-04-19  0:49 UTC (permalink / raw)
  To: 19896-done

Version: 25.1

asparagus@comcast.net wrote:

> Add the following to the description of M-x sort-columns:
> "A numeric argument means sort into descending order."
>
> Remove "or columns" from the description of M-x reverse-region.

Thanks; done in the source. (The versions on www.gnu.org will probably
not be updated until the next Emacs release.)





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-04-19  0:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1372534272.5818344.1424278471675.JavaMail.zimbra@comcast.net>
2015-02-18 17:35 ` bug#19896: 23.1; reverse-region is slow compared to sort-columns asparagus
2015-02-18 18:29   ` Ivan Shmakov
2015-02-18 19:01     ` Eli Zaretskii
2015-02-18 19:13       ` Ivan Shmakov
2015-02-18 19:29         ` Eli Zaretskii
     [not found]   ` <1358494426.5913572.1424285832847.JavaMail.zimbra@comcast.net>
2015-02-18 19:19     ` bug#19896: asparagus
     [not found]   ` <215096857.10629626.1424972910085.JavaMail.zimbra@comcast.net>
2015-02-26 17:53     ` bug#19896: Please modify documentation to close this bug asparagus
2015-04-19  0:49       ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).