0

Hi ,

I have a 2 D matrix which is a vector <vector> type. I wan to find out the unique rows. To use std::unique the rows have to be sorted. I tried using std::sort with a predicate. But sorting does not work . Could someone help me

```
typedef std::vector<float> Vec_float;
typedef std::vector<Vec_float> matrix_float;
//this function is a predicate for sorting the matrix and then eliminating duplicates
bool sort_pred (Vec_float i , Vec_float j)
{
bool val=true;
for(int it=0;it< i.size();++it)
{
if (i[it]!=j[it])
{
val=false;
return(val);
}
}
return val;
}
//this is the actual sorting function
void vec_vec_sort (matrix_float& ext_met)
{
std::sort(ext_met.begin(),ext_met.end(),sort_pred);
//unique function removes consecutive duplicates in a range
//the return value of unique is
//A forward iterator pointing to the new end of the sequence, which now does not include the elements that were consecutive duplicates.
matrix_float::iterator it;
it=std::unique(ext_met.begin(),ext_met.end());
//removing unwanted duplicate elements
ext_met.erase(it,ext_met.end());
}
```