[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in sort!?

From: Bob Proulx
Subject: Re: Bug in sort!?
Date: Mon, 22 Jul 2002 10:21:58 -0600
User-agent: Mutt/1.4i

> I can't believe it, but the sort command appears to have a sorting bug!

Don't believe it!  :-)

> I'm running version 2.0.14 on RedHat 7.3.

Your vendor set LANG for you to en_US because they think you like it
that way.  If you disagree then you should file a bug report with

Run the 'locale' command to dump the contents of your current
settings.  If it does not say "POSIX" then you are not getting a
standard sort ordering.

> If I put these 3 lines in a file 'foo'...
> packages/YCC Form.pm
> packages/YCC/Form HistoryForm.pm
> packages/YCC/Form PropertyForm.pm
> and then type 'sort foo', I get...
> packages/YCC/Form HistoryForm.pm
> packages/YCC Form.pm
> packages/YCC/Form PropertyForm.pm

Yes.  A common ailment.  As you can see the spaces and punctuation are
ignored and case is ignored in the sort.

> I'd love to hear a logical explanation for this! :)

Here is a standard reply. 


Please check out the FAQ section on sort.


This is due to the fact that you or your vendor have set environment
variables that direct the program to use locale specific sorting
tables which do not sort as you expect. You or your vendor have
probably set environment variables like LANG, LC_ALL, or LANG to
en_US. There appears to be a problem with that table on some systems
which is not part of the GNU program but part of your vendor's system

Unset them, and then set LC_ALL to POSIX.

  # If you use bash or some other Bourne-based shell,
  export LC_ALL=POSIX

  # If you use a C-shell,
  setenv LC_ALL POSIX

and it will then work the way you expect because it will use a
different set of tables.

See the standards documentation for more information on the locale
variables with regards to sort.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]