Sorting separately over different attributes in django
<p>I have a mongodb collection of ~80,000 documents. I want to display the top 200 documents per attribute on a webpage, where the user can sort by different attributes by using a dropdown menu on the webpage.</p>

<p>At the moment I'm returning a queryset per attribute and then combining them, but this is super slow: </p>

<pre><code>from itertools import chain

tall_people =  People.objects().order_by('-height')[:200]
heavy_people = People.objects().order_by('-weight')[:200]
old_people = People.objects().order_by('-age')[:200]
rich_people = People.objects().order_by('-wealth')[:200]

people = list(set(chain(tall_people, heavy_people, old_people, rich_people)))

for person in people:
    do something....
</code></pre>

<p>Is there a more efficient way to do this?</p>