Both are not possible. (And the second one will never be possible: you can not do that in any language)
The first one can be implemented, possibly, but the second one is complete nonsense: because TSortArray needs to be specialized first to be able to have a valid cast type.
You can never hard cast to an unknown type. A hard cast requires a known type. (pointer types are a rare exception, but in this case also never possible)