title: Making a python user-defined class sortable, hashable
body: <p>What methods need to be overridden/implemented when making user-defined classes sortable and/or hashable in python?</p>
  
  <p>What are the gotchas to watch out for?</p>
  
  <p>I type <code>dir({})</code> into my interpreter to get a list of methods on built-in dicts.  Of those, I assume I need to some implement some subset of</p>
  
  <pre><code>['__cmp__', '__eq__', '__ge__', '__gt__', '__hash__', '__le__', '__lt__', '__ne__']
  </code></pre>
  
  <p>Is there a difference in which methods must be implemented for Python3 as opposed to Python2?</p>