# Thread: partition a vector of vectors

1. ## partition a vector of vectors

hi,

I am working in this problem, where I have a set of N d-dimensional points, e.g. (4,5,6,8) (2,0,4,6), are 4-d points, which I have stored in a vector of vectors.

I am trying to partition the vector of vectors according to the median value of one the dimensions.

I tried to use the stl partition method like this:
Code:
```// S is a vector of vectors containing the points
vector < vector <int> >::iterator iter;
vector < vector <int> >::iterator pos_beg = S.begin();
vector < vector <int> >::iterator pos_end = S.end();

iter = partition (pos_beg, pos_end, bind2nd( is_less(d),median)  );

// "is_less" is a class I use to sort the vector of vectors according to an arbitraty dimension.
// e.g. sort(S.begin(), S.end(), is_less(d));
class is_less  {
public:
is_less(const int index = 0): i(index) {}
bool operator()(const vector<int>& v1, const vector<int>& v2) {
return v1[i] < v2[i];
}
private:
const int i;
};```
Unfortunately, it doesn't work, (or compile correctly). It seems that I have a problem with the predicate of the partition method; the bind2nd function I saw it in an example, but it worked there for just a common vector, and does not seem to work in this case.

Would anyone know how I might solve this problem with the partition.

thanks

2. I believe your operator() should be const.