What does the code zip( *sorted( zip(units, errors) ) ) do?
<p>For my application <code>units</code> and <code>errors</code> are always lists of numerical values. I tried googling what each part does and figured out the firs part of zip. It seems </p>

<pre><code>   ziped_list = zip(units, errors)
</code></pre>

<p>simply pairs the units and errors to produce a list as <code>[...,(unit, error),...]</code>. Then Its passed to sorted which sorts the elements. Since I did not provide the argument for <code>key</code>, then it compares the elements directly as the documentation implies:</p>

<blockquote>
  <p>The default value is None (compare the elements directly).</p>
</blockquote>

<p>Since the <code>ziped_list</code> is a list of tuples of integers, then it seems that it makes a comparison between tuples directly. From a small example in my terminal (python 3) it seems it compares based on the first element (even though the documentation implies the comparison is element wise):</p>

<pre><code>&gt;&gt;&gt; (1,None) &lt; (2,None)
True
&gt;&gt;&gt; (2,None) &lt; (1,None)
False
</code></pre>

<p>The last bit the unpacking and then zip still remain a mystery and I have not been  able to figure out what they do. I understand that <code>*</code> unpacks to positional argument but doing <code>*</code> doesn't let me see exactly what its doing if I try it in the command line. What further confuses me is why <code>zip</code> requires to be passed as argument an unpacked list such as <code>*sorted</code> if it already takes as an argument <code>zip(*iterable)</code> a variable called iterable. It just seems confusing (to me) why we would need to unpack something that just allows as input a list of iterables.</p>