[R] custom sort?
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri May 29 08:38:22 CEST 2009
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...
there has been some discussion on sorting here some time ago; r folks
do not seem to accept the idea of sorting as a generic task, with the
sorting algorithm a separate thing from the comparison operator and the
type of the elements to be sorted. (hence you can't sort arbitrary
lists, for example.)
you may want to lookup the archives.
More information about the R-help