So I have an array with the following structure:
typedef struct {
int order_num;
string order_day; //Sort
string client;
string tech_type;
int serial_key;
long problem;
string technician_name;
string tech_fix;
int price;
int days_spent;
string status;
string order_type;
int problems_num;
faults problems[10];
}tech_info;
The customer provides data for the second field in format dd/mm/yyyy. I need to sort the array via that input. Here is what I have so far:
bool compare(const Date& d1, const Date& d2)
{
// All cases when true should be returned
if (d1.year < d2.year)
return true;
if (d1.year == d2.year && d1.month < d2.month)
return true;
if (d1.year == d2.year && d1.month == d2.month &&
d1.day < d2.day)
return true;
// If none of the above cases satisfy, return false
return false;
}
tech_info sort_date(tech_info* all_orders[]) {
vector<string> date;
string temp;
stringstream ss(temp);
for (int i = 0; i < counter; i++) {
temp = all_orders[i]->order_day;
while (ss.good()) { //Seperate date from '/' character
string substr;
getline(ss, substr, '/');
date.push_back(substr);
}
}
}
With this hopefully I'll be able to sort the date for every entry into a string. What would be the next step? How can I use this vector that holds the date information to sort the initial array? Thank you.