There's a lot there to try and reproduce the error, especially as I don't know what's in XArray.
However, I do notice two lines and especially their comments:
orient = 2 ' top to bottom
orient = 1 'left to right

When I enumerate xlTopToBottom in code generated when recording a sort operation I get the value 1. Could this be a cause of the problem?