LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help with sorting problem (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-with-sorting-problem-927163/)

jim.thornton 02-02-2012 09:57 AM

Need help with sorting problem
 
I was curious if anyone has a way of getting my computer to sort properly?

I don't like the way linux sorts things. For example, in Thunderbird, I have folders that are of extra importance with a preceeding *** to put them to the top of the list. Thunderbird / Windows sorts them this way, but thunderbird / Linux does not.

Thunderbird / Linux ignores the *** and puts the folder in alphabetical order based on the remaining folder name.

I really need to change this behaviour. These folders were named this way for quick access and it is slowing me down dramatically having to search for the folders.

Can anyone help me please?

kbp 02-02-2012 04:41 PM

You could try a leading space on the important folders ...

jim.thornton 02-02-2012 04:44 PM

Thanks for that suggestion, but it ignores the spaces as well.

Any other ideas?

kbp 02-02-2012 05:03 PM

No, other than going the standard Yellowpages route and adding 'aaa' etc ... :)

Cedrik 02-02-2012 05:12 PM

Maybe use something like :
01_First Folder
02_Second_Folder

chrism01 02-02-2012 06:56 PM

underscores ?

jim.thornton 02-02-2012 11:43 PM

Thanks for the help guys. Cedrik: Your solution seemed to be the one that worked. The *** and ___ and pre-leading spaces are all ignored when sorting but 01___, 02___ was respected.

This is the one thing that drives me nuts with Linux, the fact that the sorting is so shotty. I mean, why in the world would you give s and S two different alphabetic values is beyond me!

Anyway... Problem solved, thanks!

chrism01 02-03-2012 12:26 AM

... because they ARE 2 different values, see any ASCII table.
Remember, all *nix systems are case sensitive, MS isn't ...

jim.thornton 02-03-2012 11:01 AM

I realize why they are sorted differently (i.e. different ascii values), but I still think that it is a major flaw with *nix systems. I wish someone would come along and change that though.

Cedrik 02-03-2012 12:24 PM

Quote:

Originally Posted by jim.thornton (Post 4592927)
I realize why they are sorted differently (i.e. different ascii values), but I still think that it is a major flaw with *nix systems. I wish someone would come along and change that though.

Everything is configurable in Unix
Try in a directory that contains files that start with upper case and lower case character :
Code:

LC_COLLATE=C ls
LC_COLLATE=en_US ls

You can set LC_COLLATE in your .bashrc or .bash_profile
Code:

export LC_COLLATE="your setting"

jim.thornton 02-03-2012 01:03 PM

Sorry, you lost me on that. Could you please explain what this commands are doing?

Cedrik 02-03-2012 01:15 PM

ls: list directory content
LC_COLLATE: This variable determines the locale category for character collation. It determines collation information for regular expressions and sorting

So in a terminal, if you type:
Code:

LC_COLLATE=C ls
and press enter, the directory listing will be sorted by ascii values (like your thunderbird does actually)

if you type:
Code:

LC_COLLATE=en_US ls
and press enter, the directory listing will be sorted in alphabetic order, which is that you want, no ?

jim.thornton 02-03-2012 01:20 PM

Yes, but is there a way to do that as a Global setting for all programs, not jut ls?

Cedrik 02-03-2012 01:24 PM

Maybe...

Instead of ls, type thunderbird (quit it before, if it is opened)
Code:

LC_COLLATE=en_US thunderbird
... and press enter

To make the change permanent, type
Code:

echo "export LC_COLLATE=en_US" >> ~/.bash_profile
...and press enter
Then log out, log in


All times are GMT -5. The time now is 05:35 PM.