O basta usare la seconda versione di sort:
http://www.cplusplus.com/reference/algorithm/sort/
Ad esempio:
codice:inline bool cmp(const CClasse1* a, const CClasse1* b) { if (a == 0 || b==0) { throw std::runtime_error("null pointer"); } return ( a->campoDaSortare < b->campoDaSortare ); } ... try { sort (vect.begin(),vect.end(),cmp); } catch (const std::exception& e) { cout << e.what() << endl; }

Rispondi quotando