Sort characters in string
Ali Çehreli
acehreli at yahoo.com
Wed Dec 6 18:32:03 UTC 2017
On 12/06/2017 04:43 AM, Fredrik Boulund wrote:
> On Wednesday, 6 December 2017 at 10:42:31 UTC, Dgame wrote:
>
>>
>> Or you simply do
>> ----
>> writeln("longword".array.sort);
>> ----
>
> This is so strange. I was dead sure I tried that but it failed for some
> reason. But after trying it just now it also seems to work just fine.
> Thanks! :)
As a general comment, sorting a string does not make sense in general
when Unicode is involved. For example, there may be combining diacriticals:
// Three characters: e, a, and combining acute accent U+0301
writeln("eá".array.sort);
prints
aé
So, the accent moves from a to e, which probably is not the intention.
Ali
More information about the Digitalmars-d-learn
mailing list