ARTS 2.5.4 (git: 31ce4f0e)
sorting.h
Go to the documentation of this file.
1/* Copyright (C) 2003-2012 Oliver Lemke <olemke@core-dump.info>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA.
17 */
18
20// File description
22
31#ifndef sorting_h
32#define sorting_h
33
34#include <algorithm>
35#include <functional>
36
37#include "array.h"
38#include "matpack.h"
39
40
56template <typename T>
57void get_sorted_indexes(ArrayOfIndex& sorted, const T& data) {
58 sorted.resize(0);
59
60 Index i = 0;
61 for (typename T::const_iterator it = data.begin(); it != data.end(); ++it) {
62 sorted.push_back(i);
63 i++;
64 }
65
66 sort(sorted.begin(), sorted.end(), [&data](const Index a, const Index b) {
67 return data[a] < data[b];
68 });
69}
70
71#endif /* sorting_h */
This file contains the definition of Array.
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
void get_sorted_indexes(ArrayOfIndex &sorted, const T &data)
get_sorted_indexes
Definition: sorting.h:57
#define a
#define b