Fix compare methods and use type_code in __cmp__

I guess that doesn't matter since `TypeID` is an `enum` and you are just comparing enumerators.