Ok, I can't fully analyze your code since I don't know what values some variables have. However, it's become clear to me your are not correct in sorting the 6th column separated by char 9. Sorting the wrong column will result in what you see happening. This points to a bug in secondary sorting though, in my opinion.
See what happens when you sort on "5 9" or "7 9". The first one is more likely.
P.S. In your last example of text format, you would of course expect the filter sort to be done for "3 9" and not "6 9" since there are only 3 columns there (unfortunately -1 is not supported as an Nth column value).