I have 2000 vector<vector<bool>>
and each vector<bool>
contains 200 elements , I am going to sort this vector of vectors. Supposing that the elements in vector<bool>
are a one binary number.
original data:
vector 1: 1,1,1
vector 2: 1,0,1
vector 3: 0,0,0
vector 4: 1,0,0
After sorting:
vector 3: 0,0,0
vector 4: 1,0,0
vector 2: 1,0,1
vector 1: 1,1,1
It is possible to use sort
with a special predicate but surprisingly when I call sort
without a predicate it seems to work anyway.
vector<bool> A = {1, 1, 1};
vector<bool> B = {1, 0, 1};
vector<bool> C = {0, 0, 0};
vector<bool> D = {1, 0, 0};
vector < vector<bool> > v = {A,B,C,D};
sort(v.begin(),v.end());
and the order is as "after sorting" above.
Why does it work without a special predicate?