Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could create a special iterator that acted as a iterator over an array of the corresponding elements to the vector you are sorting by. You will have to create your own reference type as is the case in std::vector. You are going to want to make sure you get move semantics (assuming you are using a modern compiler) right as this will require a whole array of items to be moved and you really don't want that to mean a copy IMO. Assignment for this reference type would iterate over a row of the different vectors, assigning the corresponding value from the other reference's row to the new one.</p> <pre><code>class my_refrence_type { private: //special refrence to know which vector you are sorting by std::vector&lt;double&gt;&amp; ref_vec; //refrence so you can get an iterator from the map to preform assignment std::unordered_map&lt;std::string,std::vector&lt;double&gt;&gt;&amp; map; //a location in the vectors. this is the row number int loc; public: /* insert constructors here and other blah blah blah*/ my_refrence_type&amp; operator=(my_refrence_type&amp;&amp; x) { for(auto&amp; vec : map) { vec.second[loc] = std::move(vec.second[x.loc]); } } //a method to get the reference vector's value so you can create a comparison function double&amp; get_ref_value() { return ref_vec[loc]; } }; </code></pre> <p>So to recap, you need a special reference type that can treat a row across vectors as a single object and an iterator type over these rows. If you get that right sorting should work with plain old std::sort. It will also give you an interesting view over the vectors that might come in handy elsewhere.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload