[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sort -V strange result
From: |
Pádraig Brady |
Subject: |
Re: Sort -V strange result |
Date: |
Sat, 7 Jan 2017 13:38:38 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
On 07/01/17 11:40, Hadrien Lacour wrote:
> Hello,
>
> printf '%s\n' '1x .txt' '1 .txt' | LC_ALL=C sort -V
> gives me
> 1x .txt
> 1 .txt
>
> but in ascii, space is less than any letter ('x' in this case), so what's the
> reason behind this result?
Well the input to `sort --version` is a bit constrained.
The algorithm is described at:
https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
which says the input should only contain alphanumerics.
Specifically, '1x' and '1 ' are compared as versions here,
and the (non-alpha) space is sorted after the (alpha) 'x' as per:
https://github.com/coreutils/gnulib/blob/7d75021/lib/filevercmp.c#L59-L71
cheers,
Pádraig