On Sun, 13 Dec 2015, gregrwm wrote:

> why would "a" come before null or period in a version sort?
>
> $ sort -V<<eoi
>> 9.9
>> 9a.9
>> eoi
> 9a.9
> 9.9


I figured it out in the end -- see the links.


I don't know.  It seems very wrong to me.  More examples:


$ echo -e '9\n9a' | sort -V
9
9a

$ echo -e '9.\n9a.' | sort -V
9.
9a.

$ echo -e '9.0\n9a.0' | sort -V
9a.0
9.0

$ echo -e '9a.a\n9.a' | sort -V
9.a
9a.a

$ echo -e '9a.a\n9.z' | sort -V
9.z
9a.a


It matters whether the period is followed by a letter or a digit.
More:

$ touch 9.0 9a.0

$ ls 9.0 9a.0
9.0  9a.0

$ ls -v 9.0 9a.0
9a.0  9.0

Apparently, the "versions" being sorted, even by GNU sort, are meant to be 
filenames, and the extension of the filename has to match a specific 
pattern.  Read here:

https://www.gnu.org/software/coreutils/manual/html_node/Details-about-version-sort.html#Details-about-version-sort

So this works:

$ echo -e '9a.gz\n9.gz' | sort -V
9.gz
9a.gz

But the .0 extension doesn't match the pattern, so the -V option has 
unpredictable output.

I figured this out by reading here...

https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html

...and following the link to "Details about version sort."

Mike