Skip to content
Prev 248240 / 398506 Next

Strange result from sort: sort(c("aa", "ff")) gives "ff" "aa" with R.2.12.1 on windows 7

On Mon, 24 Jan 2011, S?ren H?jsgaard wrote:

            
It seems that you and your OS disagree about Danish, and I'm in no 
position to know which is correct.  But this is not an R issue: the 
sorting is done by OS services.
I recall that 'aa' used to sort at the end of the alphabet in Danish 
telephone books, so it seems the sort used on Windows thinks so too. 
See ?Comparison for some further details.  What I don't understand is 
that someone resident in Denmark finds this strange ....

I get exactly the same in a Danish locale on Mac OS X, for example:
[1] "ff" "aa"

and also on my Linux box (Fedora 14 with LC_COLLATE=da_DK.utf8)
[1] "ff" "aa"

en_DK is not a Danish locale (in is English in Denmark).  If you want 
an English sort, try an English locale for LC_COLLATE (there may well 
be several, hence 'an').