title: How do I sort a Django QuerySet by an external value?
body: <p>I have a dict made up of (id, rank) pairs. I'd like to perform a Django query on the ids such that the resultant queryset is ordered by rank (descending).</p>
  
  <p>Getting the queryset is easy:</p>
  
  <pre><code>rankings = {...}
  result = MyModel.objects.filter(id__in=rankings.keys())
  </code></pre>
  
  <p>It seems like the answer should involve some sort of annotation that I can use as part of the order_by but I can't figure out how to get there.</p>
  
  <p>EDIT: I neglected to mention that I need the result to be a QuerySet as this is part of a tastypie API pipeline.</p>