cannot sort an array of char

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 5 05:44:17 PST 2014


On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote:
> On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko 
> wrote:
>> Hi!
>>
>> This gives an error (cannot deduce template function from 
>> argument types):
>>
>> -----
>> import std.algorithm;
>> void main () {
>> 	char [] c;
>> 	sort (c);
>> }
>> -----
>>
>> Why is "char []" so special that it can't be sorted?
>>
>> For example, if I know the array contains only ASCII 
>> characters, sorting it sounds no different to sorting an "int 
>> []".
>
> Hmm... this doesn't work either:
>
>     import std.algorithm;
>     import std.utf;
>     void main () {
>         char [] c;
>         sort (c.byCodeUnit);
>     }
>
> But IMO it should.

https://issues.dlang.org/show_bug.cgi?id=13689


More information about the Digitalmars-d-learn mailing list