Adjusting Locale or Sort Ordering for Servers

The Issue

Red Hat Linux has recently emphasized a more user-friendly desktop environment. Certain changes to the default locale settings may affect the way that various applications sort and view certain information.

Unfortunately, some of these changes may also affect server maintenance scripts and other applications which depended on the old ordering.

Here's a small example of one issue, the order of files listed in a subdirectory from the standard utility ls output.

Example file listing with the older computer-oriented "C" language sorting rules. All capitals are sorted earlier than any lowercase letters. Any punctuation also has its own place in the sorting order. Computers (and most computer programmers) collate in this way.
$ export LC_COLLATE=C
$ $ ls -asF1
total 44
   4 ./
   4 ../
   4 .hiddendir/
   4 .hiddenrc
   4 Alphabet.txt
   4 Bingo.txt
   4 README
   4 apples
   4 bananas
   4 cherries
   4 diamonds
  Example file listing with the newer human-oriented "English" language sorting rules. Capitals and lowercase letters are interleaved. Punctuation is generally not as important as any letters. A book librarian or office secretary would probably collate this way.
$ export LC_COLLATE=en_US
$ $ ls -asF1
total 44
   4 ./
   4 ../
   4 Alphabet.txt
   4 apples
   4 bananas
   4 Bingo.txt
   4 cherries
   4 diamonds
   4 .hiddendir/
   4 .hiddenrc
   4 README

These changes enhance the human usability in many ways, because most users don't think in terms of computer codes like ASCII, they think in terms of the way their spoken and written language was taught in many years of schooling.

However, these changes also affect software which may have made certain assumptions about the way the computer's standard sorting routines would collate the results of a query. Making any kind of assumption like this is bad form, but fairly common when the routines haven't changed in many years of operation. Programs that make these assumptions may have invalid

The Solution



Contact Ed Halley by email at ed@halley.cc.
Text, code, layout and artwork are Copyright © 1996-2005 Ed Halley.
Copying in whole or in part, with author attribution, is expressly allowed.
Any references to trademarks are illustrative and are controlled by their respective owners.
Make donations with PayPal - it's fast, free and secure!