Sort – Why Different Installations Sort Punctuation Differently

cygwin;sort

I got a file with content like this:

----------- 
=========== 
-------- 
-=-=-=-=-=-

When I sort in a linux os, it comes like this:

$ sort 1.txt
=========== 
-=-=-=-=-=- 
-------- 
-----------

But when I sort in cygwin, it comes like this:

$ sort 1.txt 
-------- 
----------- 
-=-=-=-=-=- 
===========

I'm wondering why the result is not the same.
I notice that the sort version in linux is 5.97, and in cygwin is 8.24. Or it's an encoding problem?

Best Answer

This is a locale issue, compare the output of locale in your two environments, and adjust the one where you want the output changed.

For example, on Linux (the sort version or OS shouldn't matter much):

$ LC_ALL=C sort t
--------
-----------
-=-=-=-=-=-
===========
$ LC_ALL=en_US.UTF-8 sort t
===========
-=-=-=-=-=-
--------
-----------
Related Question