Sorting char arrays
bearophile
bearophileHUGS at lycos.com
Mon Mar 12 06:56:15 PDT 2012
Magnus Lie Hetland:
> The following fails, which I guess is a bug?
>
> import std.algorithm;
> void main() {
> char[] a = ['a', 'b', 'c'];
> sort(a);
> }
It's not a bug, char is meant to be a UTF-8. Two workarounds:
import std.algorithm;
void main() {
dchar[] a1 = ['a', 'b', 'c'];
sort(a1);
char[] a2 = ['a', 'b', 'c'];
sort(cast(ubyte[])a2);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list