[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28539: different outputs of sort
From: |
Eric Blake |
Subject: |
bug#28539: different outputs of sort |
Date: |
Thu, 21 Sep 2017 10:36:12 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
tag 28539 notabug
thanks
On 09/21/2017 01:56 AM, He, Yihan wrote:
> Hi,
>
> We are facing issue when using sort, could you please help us to understand
> why? Thanks a lot.
Thanks for your report. However, I suspect that the difference you are
seeing is the result of a FAQ:
https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021
namely, that you have different locale settings between your two machines.
>
> We run below command on two servers, but got different outputs. I attached
> source file (property_contexts) and two outputs
> files(sort_property_context_local.txt & sort_property_context_slave.txt).
> $sort -u property_contexts -o sort_property_context.txt
>
> As checked, we use same version of sort on that two servers:
> local:~ $sort --version
> sort (GNU coreutils) 8.21
Note that this version of sort includes 'sort --debug', which is useful
in diagnosing issues like this.
Here's a trimmed-down example that produces similar behavior for me,
with the locale being explicit:
$ printf 'a\n# b\nc\n' | LC_ALL=C sort --debug
sort: using simple byte comparison
# b
___
a
_
c
_
$ printf 'a\n# b\nc\n' | LC_ALL=en_US.utf8 sort --debug
sort: using ‘en_US.utf8’ sorting rules
a
_
# b
___
c
_
That is, in the en_US.utf8 locale, the locale instructs sort to ignore
punctuation and sort case-insensitively, whereas the C locale sorts by
strict byte order.
As such, I'm tagging this issue as not a bug, but feel free to follow up
with further information, including any evidence you might have that
there is a real bug once locales have been accounted for.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature