[Rcpp-devel] R.e. is std::sort function broken??

Christian Gunning xian at unm.edu
Thu Sep 22 12:43:24 CEST 2011

I think this is the current prize-winner of inappropriate use of Rcpp...
How about using R to sort your vector?!
This isn't really an Rcpp question, but since you asked, .push_back()
is a great way to slow yourself down.

hth :)

On Thu, Sep 22, 2011 at 3:00 AM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
>        body="
>                std::vector<double> data;
>                for(int i=0; i != 20; i++){
>                        data.push_back(i);
>                }
>                std::sort(data.front(), data.back());
>                return Rcpp::wrap(data);
>        "
> )

A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!

More information about the Rcpp-devel mailing list