I am a beginner in C++ and I am having trouble merging and sorting 'the vector of vectors of integers' and 'vector of integers'.
I have,
(1) std::vector<std::vector<int> > vector_collection;
(2) std::vector<int> vector;
and I want to make
(3) std::vector<std::vector<int> > merged; out of (1) and (2)
I wish to sort the vector (2) in increasing int value and also sort each element of (1), that is, each vector element of vector_collection in increasing value of int.
Then, I want to merge (1) and (2) and sort it with respect to the first element of each vector entry.
I will be very grateful if anyone can help me with this.
To sort integers, simple sort will be sufficient.
To 'merge' just push_back the new vector and then to sort you'll have to use the sort function with Compare argument.
Ok thank you, I have trouble doing push back integers from a std::vector<int> into a std::vector<std::vector<int> >, can I actually add elements of integers type to a std::vector<std::vector<int> >??
Here is what I am doing
std::vector<std::vector<int> > vector_collection;
std::vector<int> vector; // a vector containing integers say 0, 1, 2, 3, 4