Say I have a list of vectors of strings:

["a", "c", "duck"]

["a", "a", "f"]

["bee", "s", "xy"]

["b", "a", "a"]

I want to sort the vectors in this way:

first sorting lexicographically with respect to the element at index 0, and if there's a tie, it will be determined lexicographically with respect to the element at index 1, and if there's another tie, it will be determined lexicographically with respect to the element at index 2.

So the list above will be as follows after being sorted:

["a", "a", "f"]

["a", "c", "duck"]

["b", "a", "a"]

["bee", "s", "xy"]

How can I implement the standard library sort() function to write a method to sort a list of vectors according to the above description? I'm using C++.
Thanks. 

It's not hard to write the compare function once the length of each vector is known. But what if I don't know the length of the vectors (but I always know they are of the same length)?
Compare function for vectors of length 3:

```
bool CompareVector(vector<string>  first, vector<string>  second){
    if (first[0] < second[0])
       return true;
    if (first[1] < second[1])
       return true;
    if (first[2] < second[2])
       return true;
    return false;

}

```

So for vectors of length n, there will be n if statements. But how can I keep the number of if statements a variable?

How about this:

```
 bool CompareVector(vector<string>  first, vector<string>  second){
    for (int i=0; i< first.size(); i++)
       if (first[i] < second[i])
         return true;
    return false;

```

}

Then I can call the standard sort function:

```
sort(vector<vector<string> >input.begin(), vector<vector<string> >input.end(), CompareVector() )

```

Would this work? Thanks.