How do I sort two tuples of containers?
<p>I have two tuples, each containing containers of different types.</p>

<pre><code>std::tuple&lt;containerA&lt;typesA&gt;...&gt; tupleA;
std::tuple&lt;containerB&lt;typesB&gt;...&gt; tupleB;
</code></pre>

<p>So, as an example <code>tupleA</code> might be defined like this:</p>

<pre><code>std::tuple&lt;list&lt;int&gt;, list&lt;float&gt;&gt; tupleA;
</code></pre>

<p>The two containers, <code>containerA</code> and <code>containerB</code> are different types. <code>typesA</code> and <code>typesB</code> do not intersect. I want to sort the containers inside the tuples by their sizes, and be able to access them by their type. So, as an example</p>

<pre><code>std::tuple&lt;list&lt;int&gt;, list&lt;float&gt;&gt; tupleA {{2}, {3.3f, 4.2f}};
std::tuple&lt;deque&lt;double&gt;, deque&lt;uint8_t&gt;&gt; tupleB {{2.0, 1.2, 4.4}, {}};

auto sortedArray = sort(tupleA, tupleB);
sortedArray == {deque&lt;uint8_t&gt;, list&lt;int&gt;, list&lt;float&gt;, deque&lt;double&gt;};
sortedArray.get&lt;list&lt;float&gt;&gt;() == {3.3f, 4.2f};
std::get&lt;list&lt;int&gt;&gt;(tupleA).push_back(4);
std::get&lt;list&lt;int&gt;&gt;(tupleA).push_back(5);
std::get&lt;list&lt;int&gt;&gt;(tupleA).push_back(6);
sortedArray = sort(tupleA, tupleB);
sortedArray == {deque&lt;uint8_t&gt;, list&lt;float&gt;, deque&lt;double&gt;, list&lt;int&gt;};
</code></pre>

<p>The most important part is that I have to store <code>sortedArray</code> and that the sizes of the elements in the tuple may change. I have not been able to create such a <code>sort</code> function. The actual syntax of accessing the <code>sortedArray</code> is not important.</p>

<p>I tried to use naive indexes to the container data inside the <code>sortedArray</code>, such as using <code>std::pair&lt;A, 1&gt;</code> to refer to the second element in tuple A, however I can't access the information of the tuple through it because it is not a constexpr</p>