LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-02-2012, 09:57 AM   #1
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Rep: Reputation: 19
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?
 
Old 02-02-2012, 04:41 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
You could try a leading space on the important folders ...
 
Old 02-02-2012, 04:44 PM   #3
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
Thanks for that suggestion, but it ignores the spaces as well.

Any other ideas?
 
Old 02-02-2012, 05:03 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
No, other than going the standard Yellowpages route and adding 'aaa' etc ...
 
Old 02-02-2012, 05:12 PM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Maybe use something like :
01_First Folder
02_Second_Folder
 
Old 02-02-2012, 06:56 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
underscores ?
 
Old 02-02-2012, 11:43 PM   #7
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
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!
 
Old 02-03-2012, 12:26 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
... because they ARE 2 different values, see any ASCII table.
Remember, all *nix systems are case sensitive, MS isn't ...
 
Old 02-03-2012, 11:01 AM   #9
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
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.
 
Old 02-03-2012, 12:24 PM   #10
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Quote:
Originally Posted by jim.thornton View Post
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"

Last edited by Cedrik; 02-03-2012 at 12:26 PM.
 
Old 02-03-2012, 01:03 PM   #11
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
Sorry, you lost me on that. Could you please explain what this commands are doing?
 
Old 02-03-2012, 01:15 PM   #12
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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 ?

Last edited by Cedrik; 02-03-2012 at 01:16 PM.
 
Old 02-03-2012, 01:20 PM   #13
jim.thornton
Member
 
Registered: May 2007
Posts: 404

Original Poster
Rep: Reputation: 19
Yes, but is there a way to do that as a Global setting for all programs, not jut ls?
 
Old 02-03-2012, 01:24 PM   #14
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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

Last edited by Cedrik; 02-03-2012 at 01:26 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ sorting problem kelby0320 Programming 4 05-04-2011 04:46 PM
[SOLVED] Chemistry problem- File matching and Sorting!!! robertselwyne Programming 9 07-12-2010 11:16 PM
Having problem on sorting my files to the correct folder New2Linux06 Linux - General 3 11-04-2006 05:22 AM
sorting problem ltordsen Programming 2 11-02-2005 04:25 PM
File sorting problem Kerridis Linux - General 3 03-08-2004 11:44 PM


All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration