1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
typedef struct TGM{
double numbers ;
double SecondNumbers;
bool negative;
}TGM;
vector <TGM> tgms;
TGM tgm;
for (; firstLoop != firstLoop_end; ++firstLoop) {
for (; myNumbers != myNumbers_end; ++myNumbers) {
tgm.numbers = myNumbers->value();
tgm.SecondNumbers = SecondNumbers->value();
if (myNumbers->value() < 0) tgm.negative = true;
}
tgms.push_back(tgm);
}
|
when I loop over the vector it prints the values of the numbers without any sorting method.
1 2 3
|
for(unsigned int i=0; i < tgms.size(); ++i) {
std::cout << tgms[i].numbers << std::endl;
}
|
how can I sort the numbers from lowest to the highest value ?
I found something like for the vectors
1 2 3
|
vector<double> numbers;
// fill numbers somehow
std::sort(numbers.begin(), numbers.end());
|
but I have two different numbers in my struct, numbers and SecondNumbers.
how can I sort the numbers ? and how can I sort the SecondNumbers ?
thanks.
Last edited on