Fix bug in comparing TPMs of different dimensions

TPMs are now represented with `_LexList`s, a subclass of `list` that
allows for comparison with non-Iterables (these are always considered
smaller than the `_LexList`). This allows for lexicographical sorting
when the TPMs have different shapes.