title: Best way to find max and min of two values
body: <p>I have a function that is passed two values and then iterates over the range of those values. The values can be passed in any order, so I need to find which one is the lowest first.  I had the function written like this:</p>
  
  <pre><code>def myFunc(x, y):
      if x &gt; y:
          min_val, max_val = y, x
      else:
          min_val, max_val = x, y
      for i in range(min_val, max_val):
      ...
  </code></pre>
  
  <p>But to save some screen space, I ended up changing it to:</p>
  
  <pre><code>def myFunc(x, y):
     min_val, max_val = sorted([x, y])
     for i in range(min_val, max_val):
     ...
  </code></pre>
  
  <p>How bad is this?  Is there a better way that's still one line?</p>