lambda python function in reversing list
<pre><code>scores = []
with open("scores.txt") as f:
    for line in f:
        name, score = line.split(',')
        score = int(score)
        scores.append((name, score))
        scores.sort(key=lambda s: s[1])
for name, score in scores:
    print(name + ", " + str(score))
</code></pre>

<p>This code can be used to show a txt file looking like this (disordered):</p>

<pre><code>alpha, 3
beta, 1
gamma, 2
</code></pre>

<p>To looking like this:</p>

<pre><code>beta, 1
gamma, 2
alpha, 3
</code></pre>

<p>How can I modify the code so that it instead prints as:</p>

<pre><code>alpha, 3
gamma, 2
beta, 1 
</code></pre>

<p>Use the <a href="https://docs.python.org/3/library/functions.html#sorted" rel="nofollow"><code>reverse</code></a> argument to <code>list.sort()</code>:</p>

<pre><code>scores.sort(key=lambda s: s[1], reverse=True)
</code></pre>

<p>From the documentation:</p>

<blockquote>
  <p><em>reverse</em> is a boolean value. If set to <code>True</code>, then the list elements are
  sorted as if each comparison were reversed.</p>
</blockquote>

python