how to sort items in a list alphabetically by the letters in their respective names.
<p>I am trying to sort values in a list by the letters in their name: I want, for example,  ["8a", "8c", "8b", "8d"] to become ["8a", "8b","8c", "8d"]. Does this have something to do with a key?</p>

<blockquote>
  <p>trying to sort values in a list by the letters in their name</p>
</blockquote>

<p>The example you mentioned is very simple. Based on your requirement, below is the code using <code>re.findall()</code> and <code>sorted()</code> to sort based on letters in any order within string:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; s = ['a9d', '1a2ba', '1e2s', '1b3tr']
&gt;&gt;&gt; sorted(s, key=lambda x: re.findall("[a-zA-Z]+", x))
['1a2ba', 'a9d', '1b3tr', '1e2s']  # Sorted based on: aba, ad, btr, es
</code></pre>

python