Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have many folders in my home directory that have names that begin with special characters such as _OLD_500GB_HD or !FolderIWantToSeeAtTheTop, but for some reason these folders are sorted according to their first alphanumeric character rather than the leading special character.

So how can I force the folder to not ignore the special character, or how else can I make the sort view organize certain folders at the top or bottom of the sort? Thanks.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Nautilus follows your locale's collation rules when sorting files by name. The rules for the English locales specify that punctuation, case and accents are less important than what letters occur in the string.

If you want collation to be equivalent to strcmp() sort order (i.e. do a simple comparison of the code point values for the characters in the string), you can switch to the legacy C locale for collation.

This can be done by editing ~/.profile and adding (or modifying) a line like the following:

export LC_COLLATE=C

When you next log in, the change should take effect in all programs that were using the locale collation order.

share|improve this answer
1  
Perfect. Thanks, James. Would it be asking Nautilus too much to also maybe ignore case? In other words is there a way to get picky, i.e. ls --group-directories-first combined with sort --ignore case? –  Jason Hartley Mar 25 '12 at 1:14
1  
As I said, Nautilus doesn't implement the sorting algorithm: it defers to the locale's collation algorithm. If there were a locale with an algorithm like that then it would use it. Creation of new locales is pretty heavy weight though, so it isn't trivial. –  James Henstridge Mar 25 '12 at 2:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.