title: How does the structure key= min work in sorted method?
body: <p>My problem is basically that both of this peaces of code work proparly, however, the second solution with <strong>key = min</strong> doesn't make sence to me. How does python go through this code? Why does it ignore sorting the letters and goes straight to sorting by digits? I can't understand the underlying logics of this code. </p>
  
  <p>My code: </p>
  
  <pre><code>def order(sentence):
      return ' '.join(sorted(sentence.split(), key=lambda s: int("".join(filter(str.isdigit, s)))))
  
  
  print(order("is2 Thi1s T4est 3a"))
  </code></pre>
  
  <p>Second solution</p>
  
  <pre><code>def order(sentence):
      return ' '.join(sorted(sentence.split(), key=min))
  
  
  print(order("is2 Thi1s T4est 3a"))
  </code></pre>
  
  <p>The answer is correct in both cases: </p>
  
  <pre><code>Thi1s is2 3a T4est
  </code></pre>