title: Sort QuerySet based on the higher of two different fields
body: <p>I have this model:</p>
  
  <pre><code>class ScoringModel(model.Model):
      red_score = models.SmallIntegerField()
      blue_score = models.SmallIntegerField()
  </code></pre>
  
  <p>I'm trying to sort a query set based on whichever is greater between the two. Now, taking the sum of them wouldn't work because that means a score of 90 to 0 would have a lower rank than a score of 50 to 50, which is not what I want. (I'm trying to find a list of high scores, basically.)</p>
  
  <p>I tried adding a function inside of the model, as such:</p>
  
  <pre><code>class ScoringModel(model.Model):
      red_score = models.SmallIntegerField()
      blue_score = models.SmallIntegerField()
  
      def max_score(self):
          return self.red_score if self.red_score &gt; self.blue_score else self.blue_score
  </code></pre>
  
  <p>Which doesn't work, since the <code>order_by</code> function doesn't support function return values (ie <code>ScoringModel.objects.order_by('-max_score')</code> and <code>ScoringModel.objects.order_by('-max_score()')</code> fail to run).</p>
  
  <p>Any help would be very appreciated</p>