Sorting char arrays

Magnus Lie Hetland magnus at hetland.org
Mon Mar 12 08:04:37 PDT 2012


On 2012-03-12 13:09:18 +0000, Dmitry Olshansky said:

> Mm it should perform sort on UTF-8 buffer?

Humm -- dunno ;) The UTF-8-semantics of single characters sort of 
slipped my mind :)

> Tricky thing but worths an enhancement request.

I'm just thinking an array of anything that can be compared should 
probably be sort-able. But comparing individual UTF-8-bytes can be 
weird, indeed. So, yeah. I guess the weirdness follows from the fact 
that individual characters are considered UTF-8 :)

> If it's ASCII then try:
> sort(a.representation)
> 
> representation is in std.string IRC.

The thing is, I'm using sort() in a template, and I just happen to use 
char as the template parameter in a unit test. And since I have no 
special UTF-8 values in there, my own sort() works just fine. (Although 
maybe it shouldn't? ;)

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list