1

Possible Duplicate:
Sorting a vector of objects by a property of the object

I have a structure like below:

strcut Point
{
   int x;
   int y;
   int z;
};

I also have a generic sorting function for integers:

void sort(vector<int>);              

In my program, I need to sort an array of points std::vector frequently using different fields (i.e. x, y, or z). What can I do to convert an array of Points into an an array of integers efficiently?

Community
  • 1
  • 1
wanderer
  • 1,219
  • 1
  • 10
  • 10
  • Am I correct in saying you want to either sort by x value, y value, or z value? If so, use `std::sort` with your own predicate. – chris May 09 '12 at 21:46

0 Answers0