Changing the default sort sequence

Newer Linux distributions changed the default behaviour for sorting alphanumeric values. The characters are not sorted by their ASCII value anymore, so upper and lower case characters and also dot files are displayed in alphabetical order:

user@host: ls -a
alpha
Beta
.gamma

To switch back to the old sort sequence you'll have to change the value of the variable LC_COLLATE from de_DE or en_US to POSIX. This can be done with the following command: export LC_COLLATE=POSIX. Now the system uses the old sort sequence:

user@host: ls -a
.gamma
Beta
alpha

Notice that this change only affects the actual command line session and its children. To change this value permanently you'll have to add the command line in your personal shell configuration file, e.g. ~/.bashrc for bash users.

-- StefanHaller - 17 Apr 2008
Topic revision: r1 - 2008-04-17, StefanHaller