Ah, I see what you mean now.
Note that these tags types are only a convenience. Units are type lists of base dimensions, and being able to sort these type lists allows to always reduce composite units to the same unit type which is some sort of unification. The only thing required for sorting is for the base units to have a total order - the concrete order is irrelevant.
Without sorting capabilities, one expression might produce kg * m * s and a different expression might produce m * kg * s. Because the base units are in a different order, these expressions have different types and would not unify. If you had a total order and a way to sort according to it every time a composite expression is produced, one could always produce consistent types that unify.
Assigning each base unit a unique integer is just one of the many ways there are to give a sequence of types a total order.