Welcome to DaniWeb. Glad to see that another retired person is here.
If you put those classes into a <vector> then you can use std::sort to sort them. All you have to do is write a set of functions that will be called by sort() to return true or false. You would have one of these functions for each data member you want to sort on.
Here is an example of how to use std::sort with an array of classes. About half way down the page you will find this:
struct SAscendingDateSort
{
bool operator()(CHistoryItem*& rpStart, CHistoryItem*& rpEnd)
{
return rpStart->GetTimestamp() < rpEnd->GetTimestamp();
}
};
And a little further down
// Sort the items in ascending order
std::sort(HistoryVector.begin(), HistoryVector.end(),
SAscendingDateSort());
HistoryVector is a vector of History classes -- vector<Histor> HistoryVector;
You might also be able to do this with templates, but I'm not that great with templates so hopefully someone else can help you with that.
[edit]^^^ Good: I see Vijayan had the same idea that I posted.[/edit]