First, you'll have to create a < operator for your class and then you'll have to create a function that compares two objects of that class using the < operator and then call the sort algorithm
sort(your_vector.begin(), your_vector.end(), sort_function);
Here's a simple example
#include <iostream>
#include <vector>
#include <algorithm>
class myint
{
public:
myint(int val):itsvalue(val) {}
bool operator <(const myint & m) const { return itsvalue < m.itsvalue; }
int getitsvalue() const { return itsvalue; }
private:
int itsvalue;
};
bool myint_compare(const myint & a, const myint & b)
{
return a < b;
}
std::ostream& operator <<(std::ostream & out, const myint & m)
{
return out << m.getitsvalue();
}
int main()
{
std::vector<myint> the_ints;
for (int i = 8; i > 0; --i)
the_ints.push_back(i);
for (int i = 0; i < 8; ++i)
std::cout << the_ints[i] << std::endl;
sort(the_ints.begin(), the_ints.end(), myint_compare);
std::endl(std::cout);
for (int i = 0; i < 8; ++i)
std::cout << the_ints[i] << std::endl;
return 0;
}