'cmp'

def __cmp__(self, other):

    slen = len(self)
    for i in range(slen):
        try:
            c = cmp(self[i], other[i])
        except IndexError:
            return 1
        else:
            if c:
                return c
    return cmp(slen, len(other))
