[R] Question about Sort

Wen Huang whuang.ustc at gmail.com
Tue Nov 11 17:51:58 CET 2008


Thanks a lot Professor Ripley!

I did not go into much of the details in the help page and was hoping  
somebody could have a quick answer.

The answer you provided is indeed helpful!

Thank you.


On Nov 11, 2008, at 10:40 AM, Prof Brian Ripley wrote:

> On Tue, 11 Nov 2008, Wen Huang wrote:
>
>> Hi,
>>
>> I am wondering if there is an option to control how R sort  
>> characters on different machines.
>
> Yes, and it is described on the help page for sort:
>
>     The sort order for character vectors will depend on the collating
>     sequence of the locale in use: see 'Comparison'. The sort order
>     for factors is the order of their levels (which is particularly
>     appropriate for ordered factors).
>
> and do study the cross-reference and its references.
>
> Sorting on Mac OS X in UTF-8 locales seems broken (that is, the  
> standard C functions compare in Unicode point order irrespective of  
> language): we are working on a solution (the use of ICU. which can  
> be compiled into R >= 2.8.0).
>
>>
>> For example, on my Mac OS X
>>
>>> sort(c("H", "a"), decreasing = TRUE)
>> [1] "a" "H"
>>
>> The same command on a Linux machine gives me
>>> sort(c("H", "a"), decreasing = TRUE)
>> [1] "H" "a"
>>
>> I don't know if there is an option to control the behavior of 'sort'.
>
> Well, the posting guide did ask you to do your homework, including  
> reading the help pages.
>
>> Thanks,
>> Wen
>
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list