sort dimension in typecase properly