by steve-myers » Fri Sep 06, 2013 8:32 pm
A blank is a character, just like any other character. As such, if a blank can be compared with another character. A summary of the compare order in a character set is its collating sequence. I still recall, for example, back in the days when I rode a train as part of my commute to work. One of my fellow commuters was a gentleman with whom I had occasional professional contact with. From time to time, as it happened, we shared part of our walk from the train station to our respective work locations. I recall one of our conversations on this trek quite clearly. He complained that in EBCDIC numeric characters (e.g,, 0, 1,..., 9) compared higher than any other text character, where in ASCII numeric characters compared lower than most other text characters. In those days I rarely - if ever - had contact with ASCII. My guess is he had had a recent contact with an ASCII user who did not understand very much about the difference in collating sequences, but he did not think it reasonable that the EBCDIC collating sequence should be in this order.
Now at that point in my career I had not given any thought as to the reason the engineers that devised EBCDIC had chosen the codes, and this collating sequence issue did not seem terribly significant to me. In actual fact, it still doesn't, even though I think I understand why numbers are X'Fx', and letters are X'Cx', X'Dx' and X'Ex'.
Regardless, in both EBCDIC and ASCII a blank is lower in the collating sequence than any other character, and that explains the reason why your sorted output is not in the order you appear to expect.