all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* sort-numeric-fields sorts incorrectly
@ 2007-02-19 18:33 Eric Hanchrow
  2007-02-19 21:50 ` Glenn Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Hanchrow @ 2007-02-19 18:33 UTC (permalink / raw)
  To: bug-gnu-emacs

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.4.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2006-05-17 on rothera, modified by Debian
configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--with-x=yes' '--with-x-toolkit=athena' 'CFLAGS=-DDEBIAN -g -O2' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu''
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

* Start emacs with --no-site-file -Q
* Erase the *scratch* buffer's contents with C-x h C-w
* Type the following four lines into the *scratch* buffer:
101111
0201111
0401111
301111
* Type M-x sort-numeric-fields RET.  Note that the buffer now contains
0201111
101111
0401111
301111

This is a bug, because 0201111 is greater than 101111, and yet appears before it.

Note that this bug also appears in CVS Emacs.

Recent input:
ESC x ESC p RET C-n 0 C-n C-n C-a 0 ESC h C-n ESC x 
ESC p RET C-e 1 C-n 1 C-n 1 C-n 1 ESC h C-n ESC x ESC 
p RET C-e 1 C-n 1 C-n 1 C-n 1 ESC h C-n ESC x ESC p 
RET C-e 1 1 C-n 1 1 C-n 1 1 C-n 1 1 ESC h C-n ESC x 
ESC p RET C-@ C-e ESC w ESC : ESC ( + SPC 1 SPC C-y 
RET C-x u ESC x r e p o r t - e m TAB RET

Recent messages:
load-library: Cannot open load file: multi-occur
Loading sort...done
Transient Mark mode enabled
Undo!
Mark set
sort-skip-fields: Line has too few fields: 
Mark set
201112
Undo!
Loading emacsbug...done

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

* Re: sort-numeric-fields sorts incorrectly
  2007-02-19 18:33 sort-numeric-fields sorts incorrectly Eric Hanchrow
@ 2007-02-19 21:50 ` Glenn Morris
  0 siblings, 0 replies; 2+ messages in thread
From: Glenn Morris @ 2007-02-19 21:50 UTC (permalink / raw)
  To: Eric Hanchrow; +Cc: bug-gnu-emacs

Eric Hanchrow wrote:

> 101111
> 0201111
> 0401111
> 301111
> * Type M-x sort-numeric-fields RET.  Note that the buffer now contains
> 0201111
> 101111
> 0401111
> 301111
>
> This is a bug, because 0201111 is greater than 101111, and yet
> appears before it.

As the doc-string for sort-numeric-fields explains, values with
leading zeros are interpreted as octal. The output is correct under
this assumption. Get rid of the leading zeros before sorting if this
is not what you want.

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

end of thread, other threads:[~2007-02-19 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-19 18:33 sort-numeric-fields sorts incorrectly Eric Hanchrow
2007-02-19 21:50 ` Glenn Morris

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.