For some reason, calling `argsort()` on an rarray like this one crashes, but works on a column major xarray. ```cpp // [[Rcpp::depends(xtensor)]] // [[Rcpp::plugins(cpp14)]] #include <xtensor-r/rarray.hpp> #include <xtensor/xsort.hpp> #include <xtensor/xio.hpp> #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] void argsort_test_xarray() { xt::xarray<int, xt::layout_type::column_major> x = {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}; std::cout << x << std::endl; auto x_sort = xt::argsort(x, 0); std::cout << x_sort << std::endl; } // [[Rcpp::export]] void argsort_test_rarray() { xt::rarray<int> x = {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}; std::cout << x << std::endl; auto x_sort = xt::argsort(x, 0); std::cout << x_sort << std::endl; } ``` ```r > Rcpp::sourceCpp('~/Desktop/test.cpp') > argsort_test_xarray() {{{ 1, 2, 3}, { 4, 5, 6}}, {{ 7, 8, 9}, {10, 11, 12}}} {{{0, 0, 0}, {0, 0, 0}}, {{1, 1, 1}, {1, 1, 1}}} ```