Utility to produce sorted information. More...
Functions | |
std::vector< unsigned > | sortedIndices (const std::vector< Real > &to_sort, bool ascending) |
Produces a vector of indices corresponding to the smallest-to-biggest entries in to_sort (or biggest-to-smallest if ascending=false). More... | |
Utility to produce sorted information.
std::vector< unsigned > GeochemistrySortedIndices::sortedIndices | ( | const std::vector< Real > & | to_sort, |
bool | ascending | ||
) |
Produces a vector of indices corresponding to the smallest-to-biggest entries in to_sort (or biggest-to-smallest if ascending=false).
Eg: to_sort = {1, 2, 5, 3, -2} then this will return {4, 0, 1, 3, 2} because to_sort[4]=-2 is the least entry, to_sort[0]=1 is the next biggest, etc, and to_sort[2]=5 is the greatest. Note that this doesn't actually sort the vector to_sort, but instead just produces the indices
to_sort | vector to consider |
ascending | whether to sort in ascending order |
Definition at line 15 of file GeochemistrySortedIndices.C.
Referenced by GeochemistryConsoleOutput::output(), GeochemistryConsoleOutput::outputNernstInfo(), GeochemicalSolver::reduceInitialResidual(), GeochemicalSolver::swapNeeded(), and TEST().