-
January 9th, 2013, 11:05 AM
#1
Multiple sort options in C++
Hi
I have the following private part of a class defined as follows:
private:
struct stats {
double ISIsum;
int authorCount;
bool operator<(const stats &a) const { return ISIsum > a.ISIsum;}
} *stats_;
bool compareSortByISI(const stats &lhs, const stats &rhs);
};
This enables me to sort this struct by calling:
std::sort(stats_, stats_ + authors_->getMaximumAuthors());
My question is, what if I want to have the option to sort by authorCount or ISIsum at run time. Is there any way to do this?
I can't see how I can override operator< twice and decide which one to call at use time.
Thx
G
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|