coreutils
[Top][All Lists]
Advanced

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

version-sort ugliness or bugs


From: Vincent Lefevre
Subject: version-sort ugliness or bugs
Date: Thu, 15 Apr 2021 23:47:34 +0200
User-agent: Mutt/2.0.6+148 (869c6cc4) vl-132933 (2021-04-10)

Hi,

I'm currently using version-sort in order to get integers sorted
in strings (due to the lack of simple numeric sort like in zsh),
but I've noticed some ugliness. This may be bugs, not I'm not sure
since the description of the sorting method in the Coreutils manual
takes several pages with all its exceptions, and I expect no-one
will try to understand.

Here are some examples with coreutils 8.32-4+b1 under Debian/unstable
with the following locales:

$ locale
LANG=POSIX
LANGUAGE=
LC_CTYPE=C.UTF-8
LC_NUMERIC="POSIX"
LC_TIME=en_DK.utf8
LC_COLLATE=POSIX
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

in case this matters for version-sort.

$ printf "%s\n" a.b.1 a.c a.c.0 ab.1 ac ac.0 | sort -V
a.c
ab.1
ac
ac.0
a.b.1
a.c.0

Here, one has "a.c" before "a.b.1", which is very surprising. It is
also surprising to have all these strings between "a.c" and "a.c.0",
which I would expect to be consecutive here.

$ printf "%s\n" a.aux a.fdb_latexmk a.fls a.log | sort -V
a.aux
a.fls
a.log
a.fdb_latexmk

Here, I would expect "a.fdb_latexmk" to be between "a.aux" and "a.fls".

Less important:

$ printf "%s\n" foo1 foo1.txt foo1b foo1b.txt "foo1 bar" | sort -V
foo1
foo1.txt
foo1b
foo1b.txt
foo1 bar

I think that having "foo1 bar" after something like "foo1b" is rather
unusual, because "foo1 bar" makes me think that the word "foo1" is
before "foo1b". This happens to work with lexicographic sort because
the space is the first printable character, but this is a nice feature.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

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