Fix compare methods and use type_code in __cmp__

I saw some articles saying that the numerical value is not arbitrary. First enum is given 0, the second one is given 1 and so on.