"qazmlp" <qa********@rediffmail.com> wrote in message
news:db*************************@posting.google.co m...
I have got the following strings:
121721234567890
13
1217212345
129
Is it possible to do descending sort for these strings based on their
numeric values?
After sorting, they need to figure in this order:
121721234567890
1217212345
129
13
This seems to be bit difficult for me with std::sort().
Could you help?
Its as easy with std::sort as any other way. All you need to do is write a
function that compares based on the numeric value of the string, then you
can plug that function into std::sort
bool NumericGreaterThan(const std::string& lhs, const std::string& rhs)
{
...
}
std::sort(x.begin(), x.end(), NumericGreaterThan);
Of course writing NumericGreaterThan might be a bit of a challenge.
john