sorting a string

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 14 10:59:05 PDT 2017


On 7/14/17 1:42 PM, Seb wrote:
> On Friday, 14 July 2017 at 17:28:29 UTC, Namal wrote:
>> On Friday, 14 July 2017 at 16:43:42 UTC, Anton Fediushin wrote:
>>> 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.
>>
>> Thx alot. One final question. If I do it like that. I get a 
>> deprrecation warning:
>>
>> use std.algorithm.sort instead of .sort property
>>
>> Wasn't .sort() the proper way to use it, no? Because that won't compile.
> 
> With 2.075 you want need this anymore, as the builtin properties have 
> finally been removeD:
> 
> https://dlang.org/changelog/2.075.0_pre.html#removeArrayProps

With 2.075, it won't compile even without the parentheses, because a 
char[] is not an array according to std.algorithm...

See my other post.

-Steve


More information about the Digitalmars-d-learn mailing list