title: Sorting class instances in python
body: <p>What does python 2.7 use to sort vanilla class instances? I'm interested in the default sorting behavior.</p>
  
  <p>Suppose I have the class</p>
  
  <pre><code>class S():
      pass
  </code></pre>
  
  <p>Then I can create a couple of instances, and sort them: </p>
  
  <pre><code>a = S(); b = S(); c = S()
  l = [(a,'a'), (b,'b') ,(c, 'c')]
  sorted(l)
  </code></pre>
  
  <p>This will print some sorting of the objects. Now I have a two part question:</p>
  
  <ul>
  <li>Is python using the objects' <code>__hash__()</code>, and thus their <code>id()</code>? </li>
  <li>Is it possible to override <code>__hash__()</code> to influence the sorting behavior?</li>
  </ul>