Subject: Re: bug#19142: sort not working with LANG set to language_country.encoding
From: Eric Blake <[email-masked]>
To: Roland Sieker <[email-masked]>, [email-masked]
Date: Fri, 21 Nov 2014 09:59:20 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

tag 19142 notabug
thanks

On 11/21/2014 04:24 AM, Roland Sieker wrote:
> Hi.
> 
> I have noticed that sort seems to have problems when the LANG environment
> variable is set with language and country.
> 

Thanks for the report.  The whole point of locales is that each locale
is free to choose the collation sequences that make the most sense for
that locale.

> It sorts OK like this, with LANG just the language.encoding:
> ( setenv LANG en.UTF-8 ; echo 'a\nb\na\n⺌\n⺕\n⺌' | sort )

[I'm translating your csh syntax into more-reliable sh syntax]
Try turning on sort debugging:

$ printf 'a\nb\na\n⺌\n⺕\n⺌' | LC_ALL=en.UTF-8 sort --debug
sort: using simple byte comparison
a
_
a
_
b
_
⺌
___
⺌
___
⺕
___

> But not with LANG as language_country.encoding:

$ printf 'a\nb\na\n⺌\n⺕\n⺌' | LC_ALL=en_GB.UTF-8 sort --debug
sort: using ‘en_GB.UTF-8’ sorting rules
⺌
__
⺕
__
⺌
__
a
_
a
_
b
_

That just means that whoever wrote the en_GB.UTF-8 locale picked a
different collation sequence for non-ascii characters than the person
that wrote the generic en.UTF-8 locale.  That's not a bug in sort, so
I'm closing this as not a bug from coreutils' perspective.  Feel free to
raise it as a glibc bug (the owner of locale definitions on GNU/Linux
systems) if you have a strong reason why different locales should be
more consistent on their choice of collation sequences.  And feel free
to reply further to this bug with more questions or comments, even
though it has been closed.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org