I have a vector which contains alpha numeric string and I want to sort the vector based on the numeric value.
For example, if my vector contains these values:
name0 name20 name15 name3 name10, my sorted vector should look like this:
name0 name3 name10 name15 namw20.
Can anyone please help how to do this..? Here is my complete code:
#include<vector>
#include<string>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
vector<string> temp;
temp.push_back("name0");
temp.push_back("name20");
temp.push_back("name15");
temp.push_back("name3");
temp.push_back("name10");
sort(temp.begin(), temp.end());
for (vector<string>::size_type i = 0; i!= temp.size(); i++)
cout << temp[i] << endl;
return 0;
}