[R] custom sort?

Duncan Murdoch murdoch at stats.uwo.ca
Fri May 29 01:25:28 CEST 2009


On 28/05/2009 6:06 PM, Steve Jaffe wrote:
> hmm, that is what I was afraid of. I considered that but thought to myself,
> surely there must be an easier way.  I wonder why this feature isn't
> available. It's there in scripting languages, like perl, but also in
> "hardcore" languages like C++ where std::sort and sorted containers allow
> the user to provide a comparison function (even for builtin types like int).
> It's hard to believe that you have to jump through more hoops to do a custom
> sort in R than in C++ ...
> 
> 
> You put a class on the vector...
> 

Each of the things I described to you would take about a line of code, 
plus the logic of the comparisons.  So the hoops R makes you jump 
through amount to 2-4 extra lines of code.  C++  is probably going to 
take at least that much.

Duncan Murdoch




More information about the R-help mailing list