sort a string

notna notna.remove.this at ist-einmalig.de
Fri May 1 15:51:06 UTC 2020


On Friday, 1 May 2020 at 15:17:53 UTC, drug wrote:
> 01.05.2020 18:04, notna пишет:
>> 
>> hmmm, whích results in:
>>   Error: cannot use [] operator on expression of type dchar
>> 
>
> try this:
> ```D
> import std;
> void main()
> {
>     string word = "Привет";
>     dchar[] line3 = to!(dchar[])(word.dup) // make a copy to 
> get a range of mutable char
>                                            // and convert char 
> to dchar
>         .sort                              // sort it
>         .release;                          // get the sorted 
> range
>     assert(line3 == "Пвеирт");
> }
> ```

THANKS, this looks even cleaner :)


More information about the Digitalmars-d-learn mailing list