coreutils
[Top][All Lists]
Advanced

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

sort -V behaviour


From: Sven C. Dack
Subject: sort -V behaviour
Date: Mon, 31 Jul 2017 17:23:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hello,

I have a question about the -V option to sort, but first some examples:

$ echo -e "1\n1.2\n1.2.3\n1.2.3.4"|sort -V
1
1.2
1.2.3
1.2.3.4

$ echo -e "f1\nf1.2\nf1.2.3\nf1.2.3.4"|sort -V
f1
f1.2
f1.2.3
f1.2.3.4

$ echo -e "/1\n/1.2\n/1.2.3\n/1.2.3.4"|sort -V
/1
/1.2
/1.2.3
/1.2.3.4

$ echo -e "1f\n1.2f\n1.2.3f\n1.2.3.4f"|sort -V
1f
1.2f
1.2.3f
1.2.3.4f

$ echo -e "1/\n1.2/\n1.2.3/\n1.2.3.4/"|sort -V
1.2.3.4/
1.2.3/
1.2/
1/

My question is, why does the -V option reverse the order in the last case?

This behaviour is unintuitive and seems wrong to me. When -V sorts version numbers of files/lines/etc. and assumes a version number of i.e. "1.2.3" to be higher than "1.2" then it shouldn't matter if the version number is part of a file or a directory name.

Can somebody please explain this behaviour?

Sven




reply via email to

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