More of a question of 'why?' rather than a solution requirement. I've just been looking at the sort order of character fields in a by statement due to some rather unexpected results. So I wrote the code
This produced the attached file. Can anyone explain to me why the sort order is like this? There doesn't seem to be any rhyme nor reason to it in a lot of circumstances. Why, for example would ÿ come before y?
Code:
DEFINE TEMP-TABLE ttTest NO-UNDO
FIELD Test AS CHAR
FIELD ChrNum AS INT.
DEFINE VARIABLE lvi AS INTEGER NO-UNDO.
DO lvi = 1 TO 255:
CREATE ttTest.
ASSIGN
ttTest.Test = CHR(lvi)
ttTest.ChrNum = lvi.
END.
OUTPUT TO c:\temp\sortorder.csv.
FOR EACH ttTest
BY Test:
EXPORT DELIMITER "," ttTest.
END.
OUTPUT CLOSE.