I have a vector that contains dates in this format, DDMMMYY, e.g 12Jan14
vector<string> tempDate
When I use the STL sort, basically it will work when all of the dates are in the same year/month. 01Jan14
, 05Jan14
, 11Jan14
, etc. But when I enter 02Feb14
, it will all be messed up.
sort (tempDate.begin(), tempDate.end())
Can anyone tell me what went wrong with it?
Edit: I tried to use templates, but it doesn't work as all the string got 'split' up. I did some troubleshooting inside the sortDayMonthYear
template <class T>
bool sortDayMonthYear(T a, T b)
{
for (int i =0; i < a.size(); i++)
cout << a.at(i)<< endl;
}
What i get is something like this
0
1
J
A
N
1
4
0
2
J
A
N
1
4
Actually what I intend to do is to pass the two strings into the template function, using substr to get the day, month, year, compare and return true or false.