sorting a string

Namal via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 14 19:33:37 PDT 2017


On Friday, 14 July 2017 at 17:23:41 UTC, Steven Schveighoffer 
wrote:

> import std.string: representation, assumeUTF;
> import std.algorithm: sort;
>
> auto bytes = line.representation.dup;
> bytes.sort;
> auto result = bytes.assumeUTF; // result is now char[]


Why does it have to be char[]?

  auto bytes = line.representation.dup;
  bytes.sort;
  string result = bytes.assumeUTF;

works too.


More information about the Digitalmars-d-learn mailing list