Mitesh Singh Jat wrote:
> Thanks! Bob. I have updated mine $HOME/.profile, and it is giving desired
> results on sorting.

Oh good.

> I have an another use case where 'sort' shows different sort order,
> due to ignorance of punctuations.
> ...
> The above example shows that position of first character(alphabet) in 
> each line is considered for sorting.

Again, that is using the en_US.UTF-8 collation sequence.  If you want
a different sorting order then you must ensure that LANG, LC_COLLATE
or LC_ALL are set to the desired locale.  As you noted below.

> After exporting LANG and LC_COLLATE, 
> 
> $ export LANG=en_US.UTF-8; export LC_COLLATE=C
> $ sort sort_bug2.txt
> --wv
> --ww
> ./ h
> ./ z
> $ sort sort_bug3.txt
> --aw
> --ww
> ./ h
> ./ z
> 
> This time sort is bringing similar values together.

Right.  Without one of LANG, LC_COLLATE or LC_ALL set to a "standard"
locale sort order, or set to an language based sort order such as
en_US.UTF-8, then it will ignore punctuation and fold casew.  To
consider punctuation set the appropriate variable to C and it will
then consider case and punctuation as desired.

> Thanks! Bob and Mike, I will always have the environment
> variables set in my shell or shell script before running sort. 

Good deal.  Glad to hear that "everything is sorted out" for you.  Pun
intended! :-)

Bob

Attachment: signature.asc
Description: Digital signature

Reply via email to