1 #ifndef STAN_MATH_PRIM_MAT_FUN_SORT_INDICES_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_SORT_INDICES_HPP 20 template <
bool ascending,
typename C>
43 return xs_[i - 1] < xs_[j - 1];
45 return xs_[i - 1] > xs_[j - 1];
61 template <
bool ascending,
typename C>
64 idx_t
size = xs.size();
65 std::vector<int> idxs;
67 for (idx_t i = 0; i <
size; ++i)
70 std::sort(idxs.begin(), idxs.end(), comparator);
std::vector< int > sort_indices(const C &xs)
Return an integer array of indices of the specified container sorting the values in ascending or desc...
Primary template class for the metaprogram to compute the index type of a container.
index_comparator(const C &xs)
Construct an index comparator holding a reference to the specified container.
bool operator()(int i, int j) const
Return true if the value at the first index is sorted in front of the value at the second index; this...
int size(const std::vector< T > &x)
Return the size of the specified standard vector.