You should bundle the string and CGameSlot into a struct and make a list of those. Then, you can define the < operator such that structs are compared by the string. For example:
struct Struct1 {
string User;
CGameSlot PlayerSlot;
Struct1(const string& aUser, CGameSlot aPlayerSlot) : User(aUser), PlayerSlot(aPlayerSlot) { };
bool operator < (const Struct1& rhs) const { return User < rhs.User; };
};
Making a list of the above will allow you to do a sort afterwards by just calling sort() on the list of Struct1 that you generated. To push the elements on the list, you can construct them with:
list<Struct1> my_list;
for ....
if ...
...
my_list.push_back(Struct1((*i)->GetName(), SID));
...
my_list.sort();
mike_2000_17
Posting Virtuoso
2,137 posts since Jul 2010
Reputation Points: 1,634
Solved Threads: 457