Typing enhancements for type checking values based on physical dimensions: Sorted

And I guess I’m asking for help in thinking through how much of this can already be accomplished with current type hint tools, and what specific tools would need to be added in order to be able to write this kind of thing.

I’m pretty sure the most important bit is the Sorted[] bit. But I think there are probably others missing too.

If these tools existed… I wonder if writing DimMultiply and DimDivide might look something like this (some of this syntax is made up!!):

DimMultiply = Tuple[
    *Join[DIVIDE,
    *Sorted[
        *Split[DIVIDE, *tuple_a][0],
        *Split[DIVIDE, *tuple_b][0]
    ],
    *Sorted[
        *Split[DIVIDE, *tuple_a][1],
        *Split[DIVIDE, *tuple_b][1]
    ]]
]
DimDivide = Tuple[
    *Join[DIVIDE,
    *Sorted[
        *Split[DIVIDE, *tuple_a][0],
        *Split[DIVIDE, *tuple_b][1]
    ],
    *Sorted[
        *Split[DIVIDE, *tuple_a][1],
        *Split[DIVIDE, *tuple_b][0]
    ]]
]

But there are lots of bugs in there.