It seems like I can define an operator for a struct and use std::sort for the sorting - the issue I'm seeing with this is that it seems like I can only define one sorting method. I'd like to define two others based on other fields. Is it possible to define more?
Otherwise, the only other thing I can think of is to move the structures into a vector and sort the vector using functions defined for each sort. I'm fine with handling it that way but I'm wondering if there is a more ideal way of handling sorting of structures in a queue by its fields.
For example, with this struct...
struct job
{
int id;
int start;
int end;
bool operator<(Process const &other) { return start < other.start; }
};
queue<jobSet>
I know I can set up a bool to sort by start...
sort(begin(jobSet), end(jobSet));
But I'm not sure how to set up another sort that works with the end field
std::sort, so that's easily achievable. You should clarify your question if this isn't what you want.