Sort the variables, putting type and covars first, in scoped order,
and then other Ids
It is a deterministic sort, meaning it doesn't look at the values of
Uniques. For explanation why it's important See Note [Unique
Determinism] in GHC.Types.Unique.