Replaced comparison-based sort with key based sort in BaseContext.unify_types() (fixes 2/3 compatibility issues).