Hi All,
I have a problem related to the sort function provided by STL.
class A{
A(string, string, int);
string itemA;
string itemB;
int itemC;
};
class B{
vector<A*> vecData;
vector<int> itemASorted;//keeps vecData indexes into sorted form
for itemA
vector<int> itemBSorted;//keeps vecData indexes into sorted form
for temA
vector<int> itemCSorted;//keeps vecData indexes into sorted form
for itemA
};
In my program, i fill my vecData with all the data avalible.
then i need to create the 3 sorted vectors where the indexes into
vecData is kept in sorted form according to the item.
i am having problem in defining compare function for the 3rd argument
of STL sort function
sort(itemASorted.begin(), itemASorted.end(), cmpFunc);
approach 1:
make cmpFunc as static member of class B,
but then it won't be able to access vecData variable which is
not static.
approach 2:
overload operator(),
but it can be done only for one item...whereas i need a vector
sorted for all the 3 items
any guesses how can i perform sorting of my items?
thanks for any help!!