sorting a string

Namal via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 14 08:56:49 PDT 2017


On Friday, 14 July 2017 at 15:15:42 UTC, Steven Schveighoffer 
wrote:


> import std.algorithm: filter;
> import std.uni: isWhite;
>
> line.filter!(c => !c.isWhite).to!string;
>
> be warned, this is going to be a bit slow, but that's the cost 
> of autodecoding.
>
> If you are looking for just removing ascii whitespace, you can 
> do it a bit more efficiently, but it's not easy.
>
> About the string sorting, you'd have to be more specific.
>
> -Steve

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.




More information about the Digitalmars-d-learn mailing list