Hello,

Suppose I have a two-dimensional stl vector (a vector of vectors), for example:

Code:
vector<vector<int> > x;
And then I want to sort the outer vectors in order of the size of their inner vectors. How do I do this?

Usually, with a one-dimensional vector, I can just create a comparison function and use the sort function. For example, if my vector is defined as:

Code:
vector<int> y;
And I want to sort if in terms of the int values of each vector element, then I can sort by using the stl::sort function, with the comparison function defined as:

Code:
static bool SortFunction(int val1, int val2)
{
     if (val1 > val2)
     {
          return true;
     }
     else
     {
          return false;
     }
};
However, with my two-dimensional vector, I use the following comparison function:

Code:
static bool SortFunction(vector<int> vec1, vector<int> vec2)
{
     if (vector1.size() > vector2.size())
     {
          return true;
     }
     else
     {
          return false;
     }
};
I get a runtime error:

"Debug Assertion Failed!
File: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\algorithm
Line 3686
Expression: invalid operator<"

Why is this?

Thanks!