Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "GeochemistrySortedIndices.h" 11 : 12 : namespace GeochemistrySortedIndices 13 : { 14 : std::vector<unsigned> 15 12874 : sortedIndices(const std::vector<Real> & to_sort, bool ascending) 16 : { 17 12874 : std::vector<unsigned> order(to_sort.size()); 18 : unsigned ind = 0; 19 : std::iota(order.begin(), order.end(), ind++); 20 12874 : if (ascending) 21 79780 : std::sort(order.begin(), order.end(), [&](int i, int j) { return to_sort[i] < to_sort[j]; }); 22 : else 23 447855 : std::sort(order.begin(), order.end(), [&](int i, int j) { return to_sort[i] > to_sort[j]; }); 24 12874 : return order; 25 : } 26 : } // namespace GeochemistrySortedIndices