sorting a string

Anton Fediushin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 14 09:43:42 PDT 2017


On Friday, 14 July 2017 at 15:56:49 UTC, Namal wrote:
> Thx Steve! By sorting string I mean a function or series of 
> functions that sorts a string by ASCII code, "cabA" to "Aabc" 
> for instance.

import std.algorithm : sort;
import std.stdio : writeln;

"cabA".dup.sort.writeln;

`dup` is used, because string cannot be modified, so a copy of 
string used instead.


More information about the Digitalmars-d-learn mailing list