Subject: bug#18893: Bug with Gnu sort program in coreutils 8.4

From: Bernhard Voelker <[email-masked]>
Date: Wed, 29 Oct 2014 23:41:17 +0100

tag 18893 notabug
thanks

On 10/29/2014 10:58 PM, Michael Yang wrote:
> sort (GNU coreutils) 8.4 yields:
> 
> CC = aCC
> CC = cc
> CCFLAGS =
> CC = gcc

Newer builds of sort include a --debug flag that show you what is going on:

  $ printf "CC = gcc\nCC = aCC\nCCFLAGS =\nCC = cc\n" | src/sort --debug
  src/sort: using ‘en_US.UTF-8’ sorting rules
  CC = aCC
  ________
  CC = cc
  _______
  CCFLAGS =
  _________
  CC = gcc
  ________

versus

  $ printf "CC = gcc\nCC = aCC\nCCFLAGS =\nCC = cc\n" | LC_ALL=C src/sort --debug
  src/sort: using simple byte comparison
  CC = aCC
  ________
  CC = cc
  _______
  CC = gcc
  ________
  CCFLAGS =
  _________

You have hit an FAQ:
https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021

Your current locale has chosen a collation sequence that ignores blanks
and the equal sign, so sort is sorting correctly.  Set LC_ALL in the
environment of sort to a different locale if you want bytewise sorting.

Have a nice day,
Berny