You can supply a predicate to the
sort template from <algorithm> that does the comparison:
#include <algorithm>
#include <vector>
void sort_object_list ( std::vector<sometype>& object_list )
{
struct compare {
bool operator() ( const sometype& a, const sometype& b )
{
return a.z < b.z;
}
};
std::sort ( object_list.begin(), object_list.end(), compare() );
}
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Offline 11,807 posts
since Sep 2004