[R] lexicographic sort

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Mar 16 08:00:11 CET 2002


On Fri, 15 Mar 2002, Makram Talih wrote:

> Hello,
>
> What is the rule R uses for lexicographical sort. For example,

It depends on the locale.

> sort("b","a") returns [1] "a" "b"

I get an error for that: it is incorrect usage.  I think you meant

sort(c("b","a"))

etc, for which the results are consistent in 1.4.1 in my locale.

Are you using a current version of R (not that the usage has ever been
right AFAIK)?


> sort("b", " ") returns [1] " " "b"
>
> which seems to imply a space character has priority. But
>
> sort("jam on", "jambon") returns [1] "jambon" "jam on"
>
> Why does the rule change? Any hints/suggestions?

Read the help page?

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list