我可以不按遞減使用Rcpp
RCPP降序排序
升序排序順序排序
NumericVector sortIt(NumericVector v){
std::sort(v.begin(), v.end(), std::greater<int>()); // does not work returns ascending
return v;
}
和
NumericVector sortIt(NumericVector v){
std::sort(numbers.rbegin(), numbers.rend()); // errors
return v;
}
FWIW,一個'RCPP :: NumericVector'是'double's,不'int's一個矢量,所以你可能想用'的std ::更大'。 –
確實,這個工作。謝謝! – JohnCoene