Skip to content

Instantly share code, notes, and snippets.

@gghatano
Last active January 3, 2016 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gghatano/8399642 to your computer and use it in GitHub Desktop.
Save gghatano/8399642 to your computer and use it in GitHub Desktop.
STL sort with Rcpp
# install.packages(c("Rcpp", "inline"))
library(Rcpp)
library(inline)
# sort_stl
src <- "
NumericVector x(xx);
std::sort(x.begin(), x.end());
return x;
"
stlsort <- cxxfunction(signature(xx="numeric"), src, plugin = "Rcpp")
stlsort(20:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment