title: Java's Collections.sort in Python
body: <p>I made a class in python and want to do use a function equivalent to Java's Collections.sort() method.
  I created a class called elev():</p>
  
  <pre><code>def __init__ (self, a):
      self.version = a
      self.length = int(len(a))
  
  def __lt__ (self, other):
      if self.length&gt;other.length:
          short = other.length
      else:
          short = self.length
  
      for x in range(0, short, 2):
          if not int(self.version[x]) == int(other.version[x]):
              return int(self.version[x]) &lt; int(other.version[x])
  
          if x==short-1:
              if self.length&lt;other.length:
                  return True
              else:
                  return False
  
      return False
  
  def __gt__ (self, other):
      return other.__lt__(self)
  
  def __eq__ (self, other):
  
      first =  self.__lt__(other)
      second = other.__lt__(self)
  
      return (not first) and (not second)
  
  def __ne__ (self, other):
      return not self.__eq__(other)`
  </code></pre>
  
  <p>And now I want something like collections.sort(objects) that java has. I created all the 'comparable' - which function do I call to sort my Objects array?</p>