I have C++ code. There is a vector of class. I need to sort this vector in a bit custom way.
Here is my class:
class Sales
{
public:
string customer_name;
string category;
string aircraft;
string day;
string time;
int week;
int ticket_price;
string payment;
public:
Sales () {
customer_name = "";
category = "";
aircraft = "";
day = "";
time = "";
week = 0;
ticket_price = 0;
payment = "";
}
Sales (string f_cat, string airc, string xday, string xtime, int xweek) {
customer_name = "";
category = f_cat;
aircraft = airc;
day = xday;
time = xtime;
week = xweek;
ticket_price = 0;
payment = "";
}
};
Lets say we have:
vector <Sales> list;
Imagine that list has got populated record And I want to get this sorted like below logic:
sort_string = day + time + week + category + aircraft;
Example records:
Sunday, 12:00, 1, Comm, b777
Monday, 10:00, 1, Comm, b777
Monday, 10:00, 1, Comm, a321
Monday, 12:00, 1, Comm, a321
Friday, 09:00, 1, Comm, a321
Expected Sort:
Monday, 10:00, 1, Comm, a321
Monday, 10:00, 1, Comm, b777
Monday, 12:00, 1, Comm, a321
Friday, 09:00, 1, Comm, a321
Sunday, 12:00, 1, Comm, b777
Is this possible? if Yes, then how?
Thanks.