Combining Indices of Two Sorted Lists to Form a Third SuperSorted List
<p>I have two lists <code>['AAPL', 'MMM', 'AMAT']</code> and <code>['AMAT', 'AAPL', 'MMM']</code> and I want to create a third list based on the positions of each string in its respective list.</p>

<p>For example: 
<code>AAPL</code> ranks 1st + 2nd = total 3, <code>MMM</code> ranks 2nd and 3rd = total 5, <code>AMAT</code> ranks 1st and 3rd = total 4. </p>

<p>Final list would be (by decreasing cumulative position) <code>['AAPL', 'AMAT', 'MMM']</code>. </p>

<p>I don't even know where to begin with this. </p>

<p>Just take one and do sort it by cumulative position.</p>

<pre><code>&gt;&gt;&gt; a, b = ['AAPL', 'MMM', 'AMAT'], ['AMAT', 'AAPL', 'MMM']
&gt;&gt;&gt; sorted(a, key=lambda x: a.index(x) + b.index(x))
['AAPL', 'AMAT', 'MMM']
</code></pre>

python list