Altered dimensions to use SortedKeysDict

This ensures that dimensions are always iterated over in sorted order without
imposing any overhead.