Fix compare methods and use type_code in __cmp__

Yes, it's described here: http://en.cppreference.com/w/cpp/language/enum