Sorting char arrays

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Mar 12 06:09:18 PDT 2012


On 12.03.2012 16:51, Magnus Lie Hetland wrote:
> The following fails, which I guess is a bug?
>
> import std.algorithm;
> void main() {
> char[] a = ['a', 'b', 'c'];
> sort(a);
> }
>
> I thought maybe I'd report it -- sort of surprises me that it hasn't
> been reported before, but I couldn't find it (although I found some
> similar reports) in the Bugzilla. (No biggie for me, though; the Phobos
> sort seems to fail with all kinds of things, so I have my own anyway... ;)
>
Mm it should perform sort on UTF-8 buffer? Tricky thing but worths an 
enhancement request.

If it's ASCII then try:
sort(a.representation)

representation is in std.string IRC.
-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list