For Polytonic Greek, however, it fails. There is no built-in sort order for Polytonic Greek, so I’ve added my own:
Note the plethora of accented vowel variant in square brackets after each base vowel. As far as I understand the instructions on the page linked to above, this is how I should indicate that diacritics should be ignored.
Unfortunately, it doesn’t work: all accented vowels just end up at the end of the list (in seemingly random order). If I remove the brackets, it sort-of-kind-of works, in that accented vowels are then at least ordered with the base vowel instead of at the end of the alphabet – but they’re still treated as a separate letter, so a sequence like (correctly sorted) ἑβή - ἔξα - εὐνοῖα - ἐώρων ends up as εὐνοῖα - ἐώρων - ἑβη - ἔξα.
Am I doing something wrong here, or does the script just not work properly for Polytonic Greek? And if it doesn’t, is there a better way to sort Polytonic Greek paragraphs while maintaining formatting?
The problem was that I never added the Greek diacritics. That's now fixed (the update is on the web). There's still a strange problem with some characters. Some accented lower-case upsilons and iotas aren't converted properly (yet), you may still see some mishaps there. I haven't yet figured out the correct mapping.
There's an error in your sort-order string:
Ah, that explains it! New version tested, and I can confirm it now sorts correctly; I didn’t have any accented lowercase iotas or ypsilons (ypsila?) that didn’t work in the sample I tested on. (And good catch on the sort-order string – something must have gone awry there.)
I was not aware of Marc’s more advanced script, but I just downloaded it and that works perfectly too.