How can i sort down this struct only with the int ?
struct buch {
string buchtitel;
int preis;
} buch;
How can i sort down this struct only with the int ?
struct buch {
string buchtitel;
int preis;
} buch;
If this is C++11 you can use a lambda function.
std::sort
(
beginIter, endIter,
[]( buch const& lhs, buch const& rhs ){ return lhs.preis < rhs.preis; }
);
where beginIter
and endIter
define random-access iterators to the items you wish to sort, endIter
being one past the end of the range.