title: Django/Python unorderable types: complex() < complex() Django tutorial youtube-croach
body: <p>I'm learning Django and Python from tutorial, and most of the time there are bugs between different version of Django or Python.</p>
  
  <p>I ran into this problem "unorderable types: complex() &lt; complex()" because of this :</p>
  
  <pre><code>def top_stories(top=180, consider=1000):
      latest_stories = Story.objects.all().order_by('-created_at')[:consider]
      ranked_stories = sorted([(score(story), story) for story in latest_stories], reverse=True)
      return [story for score, story in ranked_stories][:top]
  </code></pre>
  
  <p>I found a solution that said:
  Use a key function to give stores a score:</p>
  
  <pre><code>ranked_stories = sorted(latest_stories, key=score, reverse=True)
  return ranked_stories[:top]
  </code></pre>
  
  <p>This removes the need for a decorate-sort-undecorate pattern you were using, and happily also avoids comparing individual Story instances without ordering support.</p>
  
  <p>but, it still gave me an error.  This new solution isnt comparable with a new Django/Python version?</p>