Skip to content
Back to formatted view

Raw Message

Message-ID: <20120220155621.GB30981@cs.cas.cz>
Date: 2012-02-20T15:56:21Z
From: Petr Savicky
Subject: Sorting strings
In-Reply-To: <1329746130448-4404091.post@n4.nabble.com>

On Mon, Feb 20, 2012 at 05:55:30AM -0800, statquant2 wrote:
> I did, but this does not give the answer to my question...
> Anybody knows how to tweack the behaviour of sort or how to do ?

Hi.

Try this

  Sys.setlocale("LC_COLLATE", "C") 


This comes from ?locale and reads there

     Sys.setlocale("LC_COLLATE", "C")   # turn off locale-specific sorting,
                                        #  usually

See also ?sort

     The sort order for character vectors will depend on the collating
     sequence of the locale in use: see ?Comparison?.

?Comparison

     Comparison of strings in character vectors is lexicographic within
     the strings using the collating sequence of the locale in use: see
     ?locales?.  The collating sequence of locales such as ?en_US? is
     normally different from ?C? (which should use ASCII) and can be
     surprising.  Beware of making _any_ assumptions about the
     collation order: ...

Hope this helps.

Petr Savicky.