#1: The script doesn't know that you start with text. For other types of layers, the order is pretty much arbitrary.
#2: The script makes a selection, and then obtains a path from it, and then works on the path strokes. So the output is the order in which the path2sel plugin creates strokes. Thinking about it, paths2sel probably scans lines from top, so the first stroke is the item with the "highest" pixel. And the O being a round character, is possibly a tad higher that the others to make it visually just as tall (you can also check that is extends slightly below the baseline for the same reason).
It wouldn't be hard to write a script to reorder layers by their offset.
Also, if you are working with text layers, my "ofn-path-edits" plugin has a "Break text path apart" function that works on the text path (and IIRC should preserve the character order, at least in LTR languages):
Attachment:
ksnip_20220912-124530.png [ 38.75 KiB | Viewed 489 times ]