Collation settings for LC_COLLATE to get 'a' <'A' <'b' <'B'

Is there a setting for LC_COLLATE

to get the sort order 'a' < 'A' < 'b' < 'B'

:? (see the output at the end of this post). Note: 'a' < 'A' < 'b' < 'B'

good too. Here's an example to illustrate the problem.

First, we create a bunch of empty files in the temp folder like this:

$ mkdir temp
$ cd temp
$ cat ../echo-scr 
echo > a-a
echo > a-b
echo > a-A
echo > a-B
echo > B-a
echo > B-b
echo > B-A
echo > B-B
echo > aa-a
echo > aa-A
echo > aA-a
echo > aA-A
echo > Aa-a
echo > Aa-A
echo > AA-a
echo > AA-A
$ bash ../echo-scr 

      

During installation, the "LC_COLLATE=en_US.utf8"

problem is that files starting with 'a'

are split into two groups ( 'a' < 'A'

not observed):

$ export LC_COLLATE=en_US.utf8; /bin/ls -1
a-a
a-A
aa-a
aa-A
aA-a
aA-A
Aa-a
Aa-A
AA-a
AA-A
a-b
a-B
B-a
B-A
B-b
B-B

      

Apparently "LC_COLLATE=C"

stores files starting with 'a'

together, but creates another problem - now we get 'A' < 'B' < 'a' < 'b'

, but we want 'a' < 'A' < 'b' < 'B'

(the following sort order is fine too :) 'a' < 'A' < 'b' < 'B'

.

$ export LC_COLLATE=C; /bin/ls -1
AA-A
AA-a
Aa-A
Aa-a
B-A
B-B
B-a
B-b
a-A
a-B
a-a
a-b
aA-A
aA-a
aa-A
aa-a

      

So the question is: what value LC_COLLATE

should be used to get the next sort order - 'a' < 'A' < 'b' < 'B'

(example below)?

a-a
a-A
a-b
a-B
aa-a
aa-A
aA-a
aA-A
Aa-a
Aa-A
AA-a
AA-A
B-a
B-A
B-b
B-B

      

+3


source share





All Articles